我有一个RelativeLayout
with height 参数match_parent
,在这个参数中我有另一个LinearLayout
with property layout_alignParentBottom=true
。
我正在使用此布局来显示MediaController
按钮。
以下是我期望的MediaController
但下面是我正在做的事情Lollipop 5.1
(我刚刚在布局中添加了硬编码的底部边距,这根本不是任何解决方案,因为它不能在所有设备上正常工作。)
布局隐藏在底部后退按钮栏的后面。
什么是仅根据底栏的高度从底部提供必要边距的最佳方法,因为这种布局在其他 Android 版本和早期的带有硬件后退按钮的 Android 手机中运行良好。
我的 XML 文件看起来像这样
<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>
应用主题
<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>