java - Android Lollipop 设计问题

标签 java android android-activity android-5.0-lollipop android-5.1.1-lollipop

我有一个带有高度参数match_parentRelativeLayout,其中我有另一个带有属性layout_alignParentBottom=trueLinearLayout

我使用此布局来显示 MediaController 按钮。

下面是我期望在 MediaController 中拥有的内容

enter image description here

但下面是我在 Lollipop 5.1 上得到的内容(我刚刚在布局中添加了硬编码的底部边距,这根本不是任何解决方案,因为它不能在所有设备上正常工作。)

enter image description here

布局隐藏在底部后退按钮栏后面

仅根据底部栏的高度提供必要的底部边距的最佳方法是什么,因为此布局在其他 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/

相关文章:

java - 如何每 5 秒更新一次 textview 变量

android - 通过 Adb Tcp :Ip 将 Android 连接到计算机

android - 有 Intent 的外部浏览器,后退键问题 - Android

android - singleTask 和 singleInstance 的区别

java - 由 0 个元素组成的数组。 ( java )

java - 如何在 Mockito 参数捕获器中多次捕获同一对象

java - 为每个 Minecraft-Server/Java 应用程序创建一个虚拟机是否有意义?

java - 创建树状结构

android - 获取距离地理点 100 米的位置列表

mysql - 捕获用户 Activity 日志的好工具