Android Layout XML屬性研究--android:layout_marginBottom

在如下的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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章