Asa*_*riq 7 android navigation-drawer navigationview android-navigationview
我一直在尝试在状态栏下面绘制NavigationView标题,但它仍然位于状态栏后面.
我已经android:fitsSystemWindows="true"为我的DrawerLayout和我的NavigationView 设置了属性,但无济于事.
这是XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways|snap">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我有同样的问题,在您的NavigationView上将fitsSystemWindows设置为false,保持原样休息.根据我从API> = 21的理解,NavigationView落后于状态栏
你有没有尝试setFitsSystemWindows到false在标题查看?
如果您这样做了但它不起作用,您可以通过观察onApplyWindowInsetsListener标题视图或在视图上手动设置填充顶部到您的视图NavigationView:
ViewCompat.setOnApplyWindowInsetsListener(headerView) { view, insets ->
view.setPadding(0, insets.systemWindowInsetTop, 0, 0)
insets
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3223 次 |
| 最近记录: |