2016-10-20 2 views
0

Gibt es eine Möglichkeit, meine Navigationsleiste über alles zu halten oder alles in meiner Aktivität zu überlagern oder zu überlappen?Wie halte ich meine Navigationsschublade immer auf der Oberseite? ANDROID

Ich habe diesen Code in meinem main_activity.xml

<android.support.v4.widget.DrawerLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:id="@+id/drawer_layout" 
    android:layout_weight="1" 
    > 
    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/frame_container" 
     > 
    </FrameLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     /> 

    <!-- Listview to display slider menu --> 
    <ListView 
     android:id="@+id/list_slidermenu" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:listSelector="@drawable/list_selector" 
     android:background="#FFF"/> 

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

<android.support.design.widget.TabLayout 
    android:id="@+id/tab_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#FFF" 
    android:minHeight="?attr/actionBarSize" 
    app:tabIndicatorHeight="5dp" 
    app:tabIndicatorColor="@color/colorPrimary" 
    /> 

</LinearLayout> 

Das Problem, das ich jetzt habe, ist, dass meine tablayout die ganze Zeit zeigen auch meine Navigation haben Schublade ich zeigen. Kann mir jemand dabei helfen?

Ihre Antwort wird geschätzt.

this is the screen shot of my current situation

Können Sie sehen, dass die tablayout ist immer noch da, auch wenn ich meine Navigationsleiste Show haben?

Antwort

1

Für die NavigationDrawer werden oben auf alles andere zu stellen, Ihre DrawerLayout muss das übergeordnete Layout für alle Ihre Ansichten sein.

<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_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"> 


     <android.support.design.widget.TabLayout 
      android:id="@+id/tab_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:minHeight="?attr/actionBarSize" 
      app:tabIndicatorColor="@color/colorPrimary" 
      app:tabIndicatorHeight="5dp" /> 


     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 
    </LinearLayout> 

    <!-- Listview to display slider menu --> 
    <ListView 
     android:id="@+id/list_slidermenu" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="#FFF" 
     android:choiceMode="singleChoice" /> 

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

hey @MohanadMohie sobald ich die DrawerLayout werden die Eltern verändert, und meine ganze tablayout werden auf Vollbild –

+0

Sie können die 'LinearLayout' Größe und seinen Inhalt anpassen, wie Sie wollen, solange die' DrawerLayout 'ist das übergeordnete Element des gesamten Layouts. – MohanadMohie

+0

okay, ich werde es versuchen, erste, Android Xml wirklich mich Kopfschmerzen im Vergleich zu HTML –

0

Versuchen Sie, die TabLayout Schubladeninnen Layout-

<android.support.v4.widget.DrawerLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:id="@+id/drawer_layout" 
    android:layout_weight="1" 
    > 
    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/frame_container" 
     > 
    </FrameLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     /> 

    <!-- Listview to display slider menu --> 
    <ListView 
     android:id="@+id/list_slidermenu" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:listSelector="@drawable/list_selector" 
     android:background="#FFF"/> 


<android.support.design.widget.TabLayout 
    android:id="@+id/tab_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#FFF" 
    android:minHeight="?attr/actionBarSize" 
    app:tabIndicatorHeight="5dp" 
    app:tabIndicatorColor="@color/colorPrimary" 
    /> 

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

</LinearLayout> 
Verwandte Themen