I have a RelativeLayout
with height parameter match_parent
and in this I have another LinearLayout
with property layout_alignParentBottom=true
.
I am using this layout to show MediaController
buttons.
Below is what I am expecting to have in MediaController
But below is what I am getting on Lollipop 5.1
(I have just added hard coded bottom margin to the layout, which is not at all any solution as it will not work well on all devices.)
The layout hides behind the bottom back button bar.
What will be the best way to only provide the necessary margin from bottom according to height of bottom bar as this layout works fine in other Android versions and earlier Android phones with Hardware back buttons.
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>