下面状态栏工具栏重叠 [英] Toolbar overlapping below status bar
问题描述
我想在我的活动appcompat V21工具栏。但我实现工具栏下面的重叠状态栏。我该如何解决这个问题?
下面是活动布局的xml:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直>
<包括
机器人:ID =@ + ID /工具栏
布局=@布局/工具栏/>
<的FrameLayout
机器人:ID =@ + ID /容器
机器人:layout_width =FILL_PARENT
机器人:layout_height =0dp
机器人:layout_weight =1/>
< / LinearLayout中>
工具栏查看:
< XML版本=1.0编码=UTF-8&GT?;
< android.support.v7.widget.Toolbar的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID /工具栏
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:=了minHeight?ATTR / actionBarSize
机器人:后台= />中ATTR / colorPrimary?
主题风格:
<样式名称=AppTheme父=MaterialNavigationDrawerTheme.Light.DarkActionBar>
<项目名称=colorPrimary> @色/初级< /项目>
<项目名称=colorPrimaryDark> @色/ primary_dark< /项目>
<项目名称=colorAccent> @颜色/重音和LT; /项目>
< /风格>
使用安卓fitsSystemWindows =真正的
在布局(的LinearLayout在你的情况下,根视图)。
而安卓fitsSystemWindows
是
内部属性的基础上的系统窗口,例如调整视图布局 为状态栏。如果为真,调整这一观点的填充离开 空间为系统的窗口。才会起作用,如果这观点是 一个非嵌入活性
必须是一个布尔值,无论是真或假。
这也可能是一个参考的资源(在表格 @ [包:]类型:名称)或主题属性(形式 [包:] [类型:]名。)含有这种类型的值
这对应于全局属性资源符号 fitsSystemWindows。
I want to have appcompat v21 toolbar in my activity. But the toolbar I'm implementing is overlapping below status bar. How can I fix it?
Here is the activity layout 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>
Toolbar view:
<?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" />
Theme style:
<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>
Use android:fitsSystemWindows="true"
in the root view of your layout (LinearLayout in your case).
And android:fitsSystemWindows
is an
internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.
Must be a boolean value, either "true" or "false".
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
This corresponds to the global attribute resource symbol fitsSystemWindows.
这篇关于下面状态栏工具栏重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!