標籤:android http io art 問題 html 代碼 div
之前一直沒有搞懂android:padding和android:layout_margin的差別,事實上概念非常easy,padding是站在父view的角度描寫敘述問題,它規定它裡面的內容必須與這個父view邊界的距離。margin則是站在自己的角度描寫敘述問題,規定自己和其它(上下左右)的view之間的距離,假設同一級僅僅有一個view,那麼它的效果基本上就和padding一樣了。比如我的XML layout代碼例如以下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="10dip" android:paddingRight="10dip" android:paddingTop="10dip" android:paddingBottom="10dip" ><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FF0000" android:text="@string/hello" android:paddingLeft="50dip" android:paddingRight="50dip" android:paddingTop="50dip" android:paddingBottom="50dip"android:layout_marginBottom="10dip" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FF0000" android:text="@string/hello" android:paddingLeft="50dip" android:paddingRight="50dip" android:paddingTop="50dip" android:paddingBottom="50dip" android:layout_marginBottom="10dip" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FF0000" android:text="@string/hello" android:paddingLeft="50dip" android:paddingRight="50dip" android:paddingTop="50dip" android:paddingBottom="50dip" android:layout_marginBottom="10dip" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FF0000" android:text="@string/hello" android:paddingLeft="50dip" android:paddingRight="50dip" android:paddingTop="50dip" android:paddingBottom="50dip" android:layout_marginBottom="10dip" /></LinearLayout> 那麼我會得到例如以下的效果,圖上已經非常明白的標出來差別咯。