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>