在Android的布局中,常常有人将padding和margin搞混,他们其实不一样的,padding是该控件的内部距离。
magin是该控件与其他控件之间的距离。例如
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_light"
android:orientation="vertical" >
android:padding="10dp"
android:layout_margin="10dp"
android:background="@android:color/holo_green_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test"/>
得到的布局如下: