问题描述
我有一个 frameLayout full_view
,它的可见性在第一次渲染时消失了。此外,我还有一个可见的 RelativeLayout bottom_view
,它与父级对齐到底部。
每当 bottom_view
的可见性发生变化时,我都想将此 full_view
始终放在前面。但是,当 full_view
设置为可见时,bottom_view
会隐藏。有什么办法可以始终使用 xml 将 bottom_view
锚定在前面?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="@+id/full_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
<RelativeLayout
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true" />
</RelativeLayout>
解决方法
使用这样的东西
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="@+id/full_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_above="@id/bottom_view"/>
<RelativeLayout
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true" />
在您的 FrameLayout 中添加 android:layout_above="@id/bottom_view"