工具栏在状态栏下方重叠

吸收:

我想在我的活动中使用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>
Sohaib:

使用android:fitsSystemWindows="true"你的布局(LinearLayout中在你的情况下)的根视图。并且android:fitsSystemWindows

内部属性可根据系统窗口(例如状态栏)调整视图布局。如果为true,则调整此视图的填充以为系统窗口留出空间。仅当此视图处于非嵌入式活动中时才会生效。

必须为布尔值,“ true”或“ false”。

这也可能是对包含此类型值的资源(形式为“ @ [package:] type:name”)或主题属性(形式为“?[package:] [type:] name”)的引用。

这对应于全局属性资源符号fitsSystemWindows。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章