Ich habe eine Tätigkeit, die eine DrawerLayout und NavigationView von Support-Bibliothek beherbergt. Ich setze ein Kopfzeilenlayout für die Navigationsansicht und möchte, dass die Kopfhöhe der Navigation "wrap_content" lautet. Wenn ich also die Höhe auf "wrap_content" setze, geht das Header-Layout hinter die Statusleiste.Einstellung Statusbar Polsterung NavigationView in Android
Das Ergebnis, das ich will, ist, dass die Navigationsleiste hinter der Statusleiste ziehen soll, aber die Navigation Header durch die Statusbar Höhe nach unten gedrückt werden sollen.
Unten ist der Screenshot von dem, was ich erhalte. Beachten Sie die Schaltfläche "ANMELDEN" hinter der Statusleiste.
Aktivität Layout
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/nav_drawer"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"></android.support.v4.view.ViewPager>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/include_toolbar"/>
<android.support.design.widget.TabLayout
app:theme="@style/ThemeOverlay.AppCompat.Dark"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabs"
/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:headerLayout="@layout/nav_header"
app:menu="@menu/menu_navigation"
android:fitsSystemWindows="true"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
Navigationsansicht Kopfaufbau
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
android:padding="16dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:gravity="bottom">
<TextView
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_user_name"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
<TextView
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_email"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
<Button
android:id="@+id/button_sign_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign In"/>
</LinearLayout>
Ich habe nach einer Lösung gesucht, aber durch Stackoverflow kann sie nicht finden. Also bitte etwas Licht. Danke im Voraus.
Glück gehabt auf Dies? – swooby