標籤:
轉自:http://blog.csdn.net/yanfangjin/article/details/7393023
在如下的xml設定檔中,起初對於android:layout_marginBottom,即需要控制imagebutton對於向下的間距,則不能working。
<RelativeLayout
android:id="@+id/bar"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/ic_bar_bg"
android:layout_alignParentRight="true"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="@drawable/ic_frame"/>
</RelativeLayout>
查看很多的blog,對於releated layout的設定有一定的瞭解,後續測試中,添加了如下的設定android:layout_alignParentBottom="true",則能夠使用layout_marginBottom這個特性,因此認為預設的設定,alignParantBottom肯定是false,因此layout_marginBottom不起作用。
<RelativeLayout
android:id="@+id/bar"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/ic_bar_bg"
android:layout_alignParentRight="true"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:background="@drawable/ic_frame"/>
</RelativeLayout>
Android Layout XML屬性研究--android:layout_marginBottom (轉載)