安卓开发设置视图的间距 学习笔记

java yekong 432℃

设置视图的间距有两种方式:
采用layout_margin属性,它指定了当前视图与周围平级视图之间的距离。包括layout_margin、
layout_marginLeft、 layout_marginTop、 layout_marginRight. layout_marginBottom
采用padding属性,它指定了当前视图与内部下级视图之间的距离。包括padding、 paddingLeft、paddingTop、 paddingRight paddingBottom

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
        <TextView
            android:id="@+id/tv_hello"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:padding="20dp"
            android:text="@string/name"
            android:textSize="30sp"
            android:textColor="#00ff00"
            android:background="@color/white"
            ></TextView>
</LinearLayout>
喜欢 (0)