我有一个带有高度参数match_parent
的RelativeLayout
,其中我有另一个带有属性layout_alignParentBottom=true
的LinearLayout
。
我使用此布局来显示 MediaController
按钮。
下面是我期望在 MediaController
中拥有的内容
但下面是我在 Lollipop 5.1
上得到的内容(我刚刚在布局中添加了硬编码的底部边距,这根本不是任何解决方案,因为它不能在所有设备上正常工作。)
布局隐藏在底部后退按钮栏后面。
仅根据底部栏的高度提供必要的底部边距的最佳方法是什么,因为此布局在其他 Android 版本和带有硬件后退按钮的早期 Android 手机中运行良好。
My XML file looks like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mypack.MyActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomLinear"
android:orientation="vertical" >
<ImageView
android:id="@+id/albumArt"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:background="@drawable/default_cover" />
<TextView
android:id="@+id/titleOfSong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:text="Title Of Song"
android:textSize="18sp" />
<TextView
android:id="@+id/albumOfSong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:text="Album Of Song"
android:textSize="16sp" />
<TextView
android:id="@+id/artistOfSong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:text="Artist Of Song"
android:textSize="18sp" />
<TextView
android:id="@+id/genreOfSong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:text="Genre Of Song"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/bottomLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
</LinearLayout>
</RelativeLayout>
App Theme
<style name="AppBaseTheme" parent="Theme.AppCompat"></style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowDisablePreview">true</item>
<item name="android:windowAnimationStyle">@null</item>
</style>
最佳答案
您的 Activity 似乎在某种程度上使用透明导航栏主题或类似的东西,允许在可见区域之外渲染 View 。
也许提供一些有关您的 Activity 的背景信息将有助于弄清楚到底发生了什么。
话虽如此,您应该在 XML 布局的根目录中使用此属性 android:fitsSystemWindows
来强制 View 仅在窗口的可见区域中呈现。
关于java - Android Lollipop 设计问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31099944/