【发布时间】:2015-06-28 12:43:52
【问题描述】:
我有一个带有高度参数match_parent 的RelativeLayout,在这个我有另一个带有属性layout_alignParentBottom=true 的LinearLayout。
我正在使用此布局来显示 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>
【问题讨论】:
-
这真的没有意义,按钮栏不是正常屏幕的一部分,并且对齐父底部不受此影响。你确定你没有负的底部边距或类似的吗?或者播放器上方的容器可能会将其推出屏幕?
-
@breakline 这些天来,我面临着奇怪的问题。是的,我确定没有负边距或类似情况。我已经发布了我的 XML 文件。
-
你尝试过 layout_gravity -> center 吗?顺便说一句,发布包含所有组件的完整 xml,更容易分析您的问题。
-
@Xplouder 我发布了完整的 XML 文件。重力中心?为什么我需要在底部显示它。
-
您找到解决方案了吗?
标签: java android android-activity android-5.0-lollipop android-5.1.1-lollipop