2017-10-21 4 views
0

私のアプリには2つのナビゲーションドロワーがあります。右側のナビゲーションドロワーのアイコンを変更するにはどうすればよいですか?私が見たすべてのリンクは、ナビゲーション・ドロワのケースについて話していて、ActionBarToggleを使って解決しました。2つのナビゲーションドロワーを持っているときに、右側のナビゲーションドローアのアイコンを変更するには

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

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_viewLeft" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer_left" /> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_viewRight" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="end" 
     android:fitsSystemWindows="true" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" 
     app:menu="@menu/activity_main_drawer_right" /> 


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

/activity_mainそのメニューを隠し、表示し

mDrawerLayout.openDrawer(Gravity.RIGHT); 

を使用してbtnMyMenuオープン引き出しをクリックすると、ナビゲーションドロワーアイコンを含めるために使用メニューになります私はツールバーを持っています。私は以下のコードもあります。ツールバー=(ツールバー)findViewById(R.id.toolbar); setSupportActionBar(ツールバー); drawer =(DrawerLayout)findViewById(R.id.drawer_layout); ActionBarDrawerToggleトグル=新しいActionBarDrawerToggle( これ、引き出し、ツールバー、R.string.navigation_drawer_open、R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); – sandeep

+0

はい。両方の引き出しにメニューオプションがあります。あなたのクラスを共有しています。それは私や他の人にいくつかのアイデアを与えるかもしれません。 – sandeep

+0

私はハンバーガーメニューのようなアニメーションをしたくありません。静的アイコンは私が欲しいものです – sandeep

答えて

2

ツールバーの左側にのみナビゲーションアイコンを表示できます。可能な解決策は、https://material.io/icons/

<?xml version="1.0" encoding="utf-8"?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:myapp="http://schemas.android.com/apk/res-auto" 
xmlns:app="http://schemas.android.com/apk/res-auto"> 
<item android:id="@+id/search" android:icon="@drawable/ic_search_white_24dp" 
    android:title="@string/search" 
    app:showAsAction="always" 
    /> 
<item 
    android:id="@+id/btnMyMenu" 
    android:icon="@drawable/ic_menu_white_24dp" 
    android:title="Right Side Menu" 
    myapp:showAsAction="always"/> 
</menu> 

からそれに応じて、それに応じ@レイアウト内部

+0

これをチェックしてくださいhttps://play.google.com/store/apps/details?id=com.myntra.android – sandeep

+0

このアプリはメニューアイテムを使用しています。メニュー項目をクリックすると、引き出しが右側から開きます –

+0

私はアクションバーのメニューを以下に持っていました。右のアイコンがファイルの下から来ていました。ここでアイコンを変更して機能しました。 xmlns:app = "http://schemas.android.com/apk/res-auto" xmlns:tools = "http://schemas.android.com/tools" tools:context = "style.smash.MainActivity"> sandeep

関連する問題