padding和margin测试

648 查看

xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:background="#c5e1b0" android:text="TextView margin only" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:background="#f6c0c0" android:text="TextView margin only" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#c5e1b0" android:padding="10dp" android:text="TextView padding only" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#f6c0c0" android:padding="10dp" android:text="TextView padding only" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:background="#c5e1b0" android:padding="10dp" android:text="TextView padding and margin" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:background="#f6c0c0" android:padding="10dp" android:text="TextView padding and margin" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#c5e1b0" android:text="TextView no padding no margin" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#f6c0c0" android:text="TextView no padding no margin" android:textSize="20sp" /> </LinearLayout>