我想在我的活动中有appcompat v21工具栏.但是我正在实现的工具栏在状态栏下面重叠.我怎么才能把它修好呢?

重叠工具栏

以下是活动布局xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
</LinearLayout>

工具栏视图:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary" />

主题风格:

<style name="AppTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
</style>

推荐答案

在布局的根视图中使用android:fitsSystemWindows="true"(在本例中为LinearLayout).

用于根据系统窗口调整视图布局的内部属性,例如

必须是布尔值,要么为"真",要么为"假".

这也可能是对资源的引用(在

这与全局属性资源符号相对应 FitsSystemWindows.

Android相关问答推荐

周期性工作请求状态停留在排队处

如何使用单个代码库使用不同的firebase项目创建多个应用程序ID apk

strings.xml中字符串数组中的占位符

在Jetpack Compose中将导航绘图显示在顶部栏下方、底部栏上方

在Jetpack Compose中实现自动换行

触发PurchasesUpdatedListener回调时,billingClient.launchBillingFlow之前设置的成员变量丢失

Android-交叉引用表中的ForeignKey用于什么?

从包含的(复合)模块导入 Kotlin 类时,Android 应用程序模块的 build.gradle.kts 未解决的引用错误

参数化类RecyclerView.Adapter的原始使用

为什么 Android Studio 中的 theme.xml 目录没有任何原色

Android:使用依赖项 ViewModelProviderFactory 初始化 ViewModel 的正确方法

ArrayList 上的 Android intent.getParcelableArrayListExtra 引发 Nullpointer 异常

React Native Android 应用程序在调试模式下运行良好,但当我们发布 apk 时,它会生成旧版本的应用程序

Jetpack Compose 动画的行为是什么?

在 Jetpack Compose 中自动滚动后面的项目

是否可以在 Kotlin 中为 mutableStateOf() 设置自定义设置器

您如何衡量条形图的 4 个类别?

插入查询室 OnConflictStrategy.REPLACE

对话框中的内容不可见

在 Compose 中使用 DeepLink 会导致无法向后导航