首页 > 解决方案 > 迁移到 sdk 30 android 11 后获得额外空间

问题描述

android 11升级后有问题

我有一个需要更新到 sdk 30 的应用程序,升级后我遇到了奇怪的 UI 问题,在 appbar 下方的容器顶部添加了一个额外的空间。当我在 sdk 升级后以较低版本运行应用程序时,它看起来很好。似乎问题仅与android 11有关。请让我知道确切的问题是什么,无法弄清楚。我尝试将材料更改为稳定版本 1.2.0 和 appcompact 版本,但没有任何变化。

使用的构建工具是:30.0.0

顶部区域有一些默认边距,在代码中没有添加这样的边距。

<com.google.android.material.appbar.AppBarLayout

        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/toolbar_title"
                style="@style/PsToolbarTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:ellipsize="end"/>
        </androidx.appcompat.widget.Toolbar>

        <View
            style="@style/Divider"
            android:layout_width="match_parent"
            android:layout_height="@dimen/divider_height"/>

    </com.google.android.material.appbar.AppBarLayout>

这包含在协调器布局中

使用此链接进行屏幕截图:https ://i.stack.imgur.com/Jns79.png

标签: androidandroid-11

解决方案


我有同样的问题。我不知道根本原因,但在我的情况下,问题是通过com.google.android.Materialbuild.gradle.


推荐阅读