Android 布局中通用的属性

android:layout_width宽度设置
android:layout_height高度设置
android:background背景图/颜色
android:layout_margin外边距
android:padding内边距

1 :margin 调整父容器与组件的边距

通过设置margin让黑色方块移动

2 :padding :设置组件内部元素的边距

通过padding让text文本移动

代码块 :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/r3"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:background="@color/black"
            android:layout_margin="100dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="70dp"
                android:text="学习安卓"
                android:textSize="28sp"
                android:padding="20dp"
                android:textColor="@color/purple_200"></TextView>
        </RelativeLayout>
    


           </RelativeLayout>


3  (一般在宽度高高度内使用): march-parent :剩余空间有多少内容空间就有多大(内容分配的空间为所有剩余空间)

wrap-content :根据内容的大小来定空间(即空间随着内容的增多而增大)

也可自行设置高度和宽度

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

m0_63911789

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值