& lt?xml版本="1.0 "編碼="utf-8 "?& gt
& lt線性布局
xmlns:Android = "/apk/RES/Android "
Android:layout _ width = " fill _ parent "
Android:layout _ height = " wrap _ content "
android:orientation="vertical "
android:padding="10dp "
& gt
& lt紐扣
Android:id = " @+id/btnaction 1 "
Android:layout _ width = " fill _ parent "
Android:layout _ height = " wrap _ content "
Android:background = " @ drawable/cool _ button "
android:text = "HiText1 "
/& gt;
& lt按鈕android:layout_marginTop="50dp "
android:id="@+id/btnAction2 "
Android:layout _ width = " fill _ parent "
Android:layout _ height = " wrap _ content "
Android:background = " @ drawable/cool _ button "
android:text="HiText2 "
Android:layout _ below = " @ id/btnaction 1 "
/& gt;?
& lt/linear layout & gt;
擴展數據
如果壹個控件設置為Android: gravity = "center | top ",那麽這個控件中的子控件位於控件中心的上半部分。
如果壹個控件設置為Android:layout _ gravity = " center | top ",那麽這個控件位於其父控件靠近頂部的中心,這是對這個控件本身位置的操作。
Android:layout_marginBottom:距元素下邊緣的距離。
Android:layout_marginLeft:距元素左邊緣的距離。
Android: layout _ margin:距元素右邊緣的距離。
Android:layout_marginTop:距元素上邊緣的距離。