9

Gerade habe ich gerade ein Projekt in Android Studio mit der Navigationsleiste wie in der Vorlage vorkonfiguriert gestartet. Anscheinend legt es die Navigationsschublade hinter die Aktionsleiste. Viele Fragen, die Sie finden, möchten, dass die Navigationsleiste oben auf der Aktionsleiste angezeigt wird. Ich möchte, dass sie unterhalb der Aktionsleiste beginnt. Dies ist, was ich derzeit haben:Navigationsschublade unter Actionbar

current situation

schließlich gewünschte Situation:

desired situation

I this Lösung gefunden zu haben, aber ich denke, es sollte einen einfacheren Weg geben.

+0

die Navigationsleiste nicht unter der ActionBar/Symbolleiste sein soll, ist es gegen die Konstruktionsführungslinien – tyczj

+0

ist es wirklich? https://developer.android.com/design/patterns/navigation-drawer.html –

+0

das sind die alten Design-Richtlinien, dies ist die aktualisierte http://www.google.com/design/spec/patterns/navigation -drawer.html – tyczj

Antwort

15

Wenden Sie dieses Attribut auf Ihre Stammsichtgruppe android:layout_marginTop="?android:attr/actionBarSize" an. Hoffe das hilft.

+0

heißt es: kann das Symbol 'actionBarSize' nicht auflösen –

+0

Sind Sie sicher? Bitte sehen Sie meine Antwort noch einmal. – Biu

+0

Fast jetzt! Es scheint nicht die Benachrichtigungsleiste in diesem Rand oben zu nehmen. –

7

Versuchen Sie, dieses MainActivity Layout:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools"> 
    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/app_bar" 
     android:theme="@style/AppTheme.AppBarOverlay"> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 
    </android.support.design.widget.AppBarLayout> 
    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="?attr/actionBarSize" 
     android:fitsSystemWindows="true"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:paddingBottom="@dimen/activity_vertical_margin" 
      android:paddingLeft="@dimen/activity_horizontal_margin" 
      android:paddingRight="@dimen/activity_horizontal_margin" 
      android:paddingTop="@dimen/activity_vertical_margin" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      tools:showIn="@layout/app_bar_main"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Put your content View here!" /> 
     </RelativeLayout> 
     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_view" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      app:headerLayout="@layout/nav_header_main" 
      app:menu="@menu/activity_main_drawer" /> 
    </android.support.v4.widget.DrawerLayout> 
</RelativeLayout> 
+0

Hallo bin ich über den Code, seine Arbeit ziemlich in SDK 23 und wenn der gleiche Code auf SDK 19 ActionbarTitle nicht angezeigt. .... Dies ist Link: http://StackOverflow.com/Questions/39957481/android-Navigation-Drawer-Ui-Different-displayed-in-below-sdk-22?noredirect=1#comment67194862_39957481 –

+0

Warum nicht benutzt du einfach layout_below? Vielleicht habe ich einen Punkt verpasst? – zgulser