0

so im Aufbau Android-Anwendung in meiner Haupttätigkeit im Verwenden von Kollaps Toolbar mit Navigationsschublade, aber die Schaltfläche "Tuggle" für die navigationDrawer nicht angezeigt. so brauche ich einen Weg, den Knebel speziell erscheinen zu lassen, wenn SymbolleisteCollapsing Toolbar mit NavigationDrawer Toggle-Taste zeigt nicht

diese vollständig zusammengebrochen ist mein content_main:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent" 
    android:layout_height="match_parent" 

    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.infinity.dev.nearby.Main2Activity" 
    tools:showIn="@layout/app_bar_main2" 
    android:background="@color/grey" 
    android:fillViewport="false"> 
    <android.support.design.widget.AppBarLayout 
     android:id="@+id/MyAppbar" 
     android:layout_width="match_parent" 
     android:layout_height="256dp" 
     android:fitsSystemWindows="true"> 
    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapse_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     app:contentScrim="@color/colorPrimary" 
     android:fitsSystemWindows="true"> 

    <ImageView 
     android:id="@+id/bgheader" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerCrop" 
     android:background="@drawable/france" 
     android:fitsSystemWindows="true" 
     app:layout_collapseMode="pin" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/MyToolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      style="@style/AppTheme" 

      app:layout_collapseMode="parallax" /> 



    </android.support.design.widget.CollapsingToolbarLayout> 


    </android.support.design.widget.AppBarLayout> 
<android.support.v4.widget.NestedScrollView...> 

</android.support.design.widget.CoordinatorLayout> 

und dies ist der activity_main.xml:

<?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" 
     android:fitsSystemWindows="true" 
     tools:openDrawer="start"> 

     <include 
      layout="@layout/app_bar_main2" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 



     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_view" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true" 
      app:headerLayout="@layout/nav_header_main2" 
      app:menu="@menu/activity_main2_drawer" 
      app:itemTextColor="#212121" 
      /> 

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

ist dies die app_bar_main.xml:

Dies ist der Code in main_activity.java verwendet:

final Toolbar toolbar = (Toolbar) findViewById(R.id.MyToolbar); 
setSupportActionBar(toolbar); 
getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapse_toolbar); 
collapsingToolbarLayout.setTitle("My Country"); 
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
drawer.setDrawerListener(toggle); 
toggle.syncState(); 

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 
navigationView.setNavigationItemSelectedListener(this);      

collapsingToolbarLayout.setContentScrimColor(ContextCompat.getColor(context,R.color.colorPrimary)); 

image of toolbar before collapse:

image of toolbar after Collapse

Antwort

1

Es zwei Grund dafür sein könnte, eine Sache zu tun versuchen zu klicken an der Stelle der Toggle-Taste, wenn es Schublade öffnet bedeutet, dass Ihr Toggle ist nicht sichtbar aufgrund der Thema-Stil Ihrer, so können Sie Co ändern lorof Ihre Toggle von Thema, sonst dieses:

<?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" 
            android:fitsSystemWindows="true" 
            tools:context=".ui.MainActivity"> 


    <android.support.design.widget.CoordinatorLayout 
       android:id="@+id/htab_maincontent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/htab_appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="?attr/colorPrimary" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/htab_collapse_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="320dp" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> 

      <ImageView 
       android:id="@+id/bgheader" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/france" 
       android:fitsSystemWindows="true" 
       android:scaleType="centerCrop" 
       app:layout_collapseMode="parallax" /> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="104dp" 
       android:gravity="top" 
       android:minHeight="?attr/actionBarSize" 

       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
       app:layout_scrollFlags="scroll|enterAlways|snap" 
       app:layout_collapseMode="pin" 

       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 


    </android.support.design.widget.AppBarLayout> 


    </android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:headerLayout="@layout/nav_header" 
    app:menu="@menu/nav_items" /> 
    </android.support.v4.widget.DrawerLayout> 



This might be useful for you ,try to use this one