How to place a RelativeLayout at the bottom of a RelativeLayout?

依然范特西╮ 提交于 2019-12-01 06:42:28
Konstantin Burov

Try adding a alignParentBottom option to the transparent panel.

<RelativeLayout    android:layout_width="wrap_content"   android:layout_height="wrap_content">    <com.google.android.maps.MapView      android:id="@+id/mapView"/>    <test.project.TransparentPanel     android:layout_width="fill_parent"     android:layout_width="fill_parent"     android:layout_alignParentBottom="true">        <Button          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="Click Me!"/>             </test.project.TransparentPanel>  </RelativeLayout>  

As Konstantin pointed out use layout_alignParentBottom to position the button at the bottom of your view. The problem now is that the mapview will also stretch itself out to the bottom of the parent. Therefore the mapview will ´grow´ under the button until the parent is filled.

Try the following. First position the button at the bottom of the parent view, then align above the button.

<RelativeLayout    android:layout_width="wrap_content"   android:layout_height="wrap_content">    <test.project.TransparentPanel     android:id="@+id/button_area"     android:layout_width="fill_parent"     android:layout_width="fill_parent"     android:layout_alignParentBottom="true">        <Button          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="Click Me!"/>             </test.project.TransparentPanel>    <com.google.android.maps.MapView      android:id="@+id/mapView"     layout_above="@id/button_area"/>  </RelativeLayout>  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!