2017-01-05 4 views
1

Derzeit habe ich eine transparente Symbolleiste mit Schubladenlayout. Es ist in einem Rahmenlayout positioniert, so dass die Schublade von der Werkzeugleiste überlappt wird, aber ich möchte, dass sie darunter ist.Transparente Werkzeugleiste mit Schubladenlayout

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    > 

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 
     <!-- Framelayout to display Fragments --> 
     <FrameLayout 
      android:id="@+id/frame_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"></FrameLayout> 

     <!-- 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:divider="@color/list_divider" 
      android:dividerHeight="1dp" 
      android:listSelector="@drawable/list_selector" 
      android:background="@color/list_background"/> 

    </android.support.v4.widget.DrawerLayout> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     android:background="@color/tb_background" 
     app:theme="@style/TransparentToolbar" 
     app:titleTextAppearance="@style/Toolbar.TitleText" 
     > 
    </android.support.v7.widget.Toolbar> 
</FrameLayout> 

Wie kann ich es so transparent Symbolleiste machen drawerlayout nicht überschneiden?

+0

add Screenshot bitte? – xFighter

+0

Ich möchte es so machen, dass die Symbolleiste nicht die Schublade Layout überlappt – user7346168

+0

Fügen Sie einen Screenshot – xFighter

Antwort

0

Zuallererst benötigen Sie kein zusätzliches Rahmenlayout für Ihr Schubladenlayout. Passen Sie Ihr Layout wie unten gezeigt an.

Statt mit der Listenansicht können Sie neue Ansicht Unterstützung Navigation für Navigationsmenü verwenden, wie es Sie von zusätzlicher Codierung speichert und gibt die App einen Standard sieht aus wie andere Android-Anwendung.

<?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/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <!-- this is the main content view --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     android:background="@color/tb_background" 
     app:theme="@style/TransparentToolbar" 
     app:titleTextAppearance="@style/Toolbar.TitleText" /> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:foreground="?android:windowContentOverlay" /> 
    </LinearLayout> 

    <!-- you used here listView --> 
    <!-- this is the navigation --> 
    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/navigation_header" 
     app:menu="@menu/navigation_menu" /> 

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

folgen der offiziellen Dokumentation unter:

Creating Navigation Drawer

NavigationView

0

Sie müssen die DrawerLayout als root Layout halten und im Inneren der FrameLayout mit Toolbar verwenden.

Etwas wie folgt aus:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
> 

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     android:background="@color/tb_background" 
     app:theme="@style/TransparentToolbar" 
     app:titleTextAppearance="@style/Toolbar.TitleText" 
     > 
    </android.support.v7.widget.Toolbar> 
    <!-- Framelayout to display Fragments --> 
    <FrameLayout 
     android:id="@+id/frame_container" 
     android:layout_marginTop="?attr/actionBarSize" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"></FrameLayout> 

</FrameLayout> 

<!-- 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:divider="@color/list_divider" 
     android:dividerHeight="1dp" 
     android:listSelector="@drawable/list_selector" 
     android:background="@color/list_background"/> 

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