2014-11-12 6 views
5

Ich versuche, meine Navigationsschublade so zu ändern, dass sie der neuen Google Mail-App ähnelt. Ich verwende AppCompatv7 - v21 und habe den aktualisierten SDK. Was fehlt mir? Bitte beachten Sie die Bilder unten.Navigationsschublade: Gmail vs AppCompatv7 v21

Gmail Navigation:

enter image description here

Die Schublade Navigation, bewegt sich über die Symbolleiste.

Meine aktuelle Navigation:

enter image description here

Die Navigationsleiste kommt unterhalb der Symbolleiste.

[EDIT]

Dies war mein früherer XML-Code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <include 
     android:id="@+id/toolbar" 
     layout="@layout/toolbar_with_spinner" /> 

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <FrameLayout 
      android:id="@+id/fragment_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 
     </FrameLayout> 

     <ListView 
      android:id="@+id/listview_drawer" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:background="@color/dark_grey" 
      android:choiceMode="singleChoice" 
      android:divider="@drawable/drawer_list_divider" 
      android:dividerHeight="2dp" /> 
    </android.support.v4.widget.DrawerLayout> 

</LinearLayout> 

nun gemäß dem Vorschlag von pedro, habe ich versucht, die Symbolleiste innerhalb drawerlayout zu bewegen.

Hier ist meine neue xml:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <include 
     android:id="@+id/toolbar" 
     layout="@layout/toolbar_with_spinner" /> 

    <FrameLayout 
     android:id="@+id/fragment_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 
    </FrameLayout> 

    <ListView 
     android:id="@+id/listview_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="@color/white" 
     android:choiceMode="singleChoice" 
     android:divider="@drawable/drawer_list_divider" 
     android:dividerHeight="2dp" /> 

</android.support.v4.widget.DrawerLayout> 

Das ist mein aktueller Code ist in onCreate()

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
     toolbar = (Toolbar) findViewById(R.id.toolbar); 
     spinner = (Spinner) toolbar.findViewById(R.id.spinner); 
     mDrawerList = (ListView) findViewById(R.id.listview_drawer); 

Nun, ich sehe nicht, auch die Symbolleiste. Hier ist das Bild.

enter image description here

[EDIT]

Hier ist mein neues Layout. Dies funktioniert .. Dank wieder pedro ...

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar_with_spinner" /> 

     <FrameLayout 
      android:id="@+id/fragment_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 
     </FrameLayout> 
    </LinearLayout> 

    <ListView 
     android:id="@+id/listview_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="@color/white" 
     android:choiceMode="singleChoice" 
     android:divider="@drawable/drawer_list_divider" 
     android:dividerHeight="2dp" /> 

</android.support.v4.widget.DrawerLayout> 

enter image description here

Antwort

5

Sie haben Ihre Symbolleiste in Ihrem Fach-Layout zu setzen. Hier

ist ein Beispiel für eine XML genommen from this Github Project:

<?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" 
             android:id="@+id/drawer" 
             android:layout_width="match_parent" 
             android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <include 
      android:id="@+id/toolbar_actionbar" 
      layout="@layout/toolbar_default" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 

     <FrameLayout 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 
    </LinearLayout> 
    <!-- android:layout_marginTop="?android:attr/actionBarSize"--> 
    <fragment 
     android:id="@+id/fragment_drawer" 
     android:name="com.poliveira.apps.materialtests.NavigationDrawerFragment" 
     android:layout_width="@dimen/navigation_drawer_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:layout="@layout/fragment_navigation_drawer"/> 
</android.support.v4.widget.DrawerLayout> 
+0

Ich habe versucht, die Symbolleiste in dem drawerlayout zu setzen, aber jetzt sehe ich nicht die Symbolleiste überhaupt. Kannst du meine bearbeitete Frage ansehen? –

+0

Wickeln Sie Ihre Symbolleiste und Ihr Rahmenlayout in ein lineares Layout. Überprüfen Sie mein Beispiel XML –

+0

Danke, jetzt funktioniert es ... Ich habe versucht, Linearelayout vor und aus irgendeinem Grund es stürzte. Es scheint, als hätte ich es damals vermasselt. Jetzt funktioniert es gut. Danke für Ihre Hilfe!!! –

0

Hier mein neues Layout ist. Dies funktioniert .. Dank wieder pedro ...

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar_with_spinner" /> 

     <FrameLayout 
      android:id="@+id/fragment_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 
     </FrameLayout> 
    </LinearLayout> 

    <ListView 
     android:id="@+id/listview_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="@color/white" 
     android:choiceMode="singleChoice" 
     android:divider="@drawable/drawer_list_divider" 
     android:dividerHeight="2dp" /> 

</android.support.v4.widget.DrawerLayout> 

enter image description here