2

I have a Navigation Drawer that opens from right to left, i have menu icons on left side but i want them on right side.How to move them to the right of menu items?screenshot

This is my menu file

<group android:checkableBehavior="single">

    <item

        android:id="@+id/nav_artsdesign_photography"
        android:title="Arts, Design and Photography"
        android:icon="@mipmap/ic_launcher"/>

    <item

        android:id="@+id/nav_biographies_autobiographies"
        android:title="Biographies and Autobiographies" />

    <item

        android:id="@+id/nav_comic_graphic_novels"
        android:title="Comic and Graphic Novels" />

    <item

        android:id="@+id/nav_computer_internet"
        android:title="Computer and Internet " />
    <item

        android:id="@+id/nav_history_politics"
        android:title="History and Politics" />
    <item

        android:id="@+id/nav_health_cooking"
        android:title="Health and Cooking" />
    <item

        android:id="@+id/nav_indian_writing"
        android:title="Indian Writing" />
    <item

        android:id="@+id/nav_international_books"
        android:title="International Books" />
    <item

        android:id="@+id/nav_medical"
        android:title="Medical" />
    <item

        android:id="@+id/nav_religion_spirituality"
        android:title="Religion and Spirituality" />
    <item

        android:id="@+id/nav_school_books"
        android:title="School Books" />
    <item

        android:id="@+id/nav_other"
        android:title="Other" />


</group>

my layout

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

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

    <FrameLayout

        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />



</LinearLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_gravity="start"
    app:headerLayout="@layout/activity_navigation_header"
    app:menu="@menu/drawer_view"


    >
    <include layout="@layout/activity_navigation_header"/>

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

please help.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
seon
  • 1,050
  • 2
  • 13
  • 27
  • You have to use custom NavigationDrawer.. – cpt. Sparrow Nov 22 '16 at 11:22
  • i got stuck.can u provide any link?? – seon Nov 22 '16 at 11:23
  • wait i'll post the answer.!! – cpt. Sparrow Nov 22 '16 at 11:24
  • i am waiting sir.please provide useful link – seon Nov 22 '16 at 11:32
  • http://www.androidhive.info/2015/04/android-getting-started-with-material-design/ see this link and change the `nav_drawer_row.xml` accordingly – cpt. Sparrow Nov 22 '16 at 11:34
  • @intellijShivam this is helpful.but it doesnot have info about move menu icons to right – seon Nov 22 '16 at 11:39
  • sir, In that there is xml file name `nav_drawer_row.xml` arrange that xml accordingly , move the image towards right in that and that will be inflated in all – cpt. Sparrow Nov 22 '16 at 11:41
  • no sir i have not any nav_drawer_row file sir – seon Nov 22 '16 at 11:53
  • that's why i'm saying to implement my navigation drawer for the link and change the xml as shown above... goto the link which i have provided download the sample code given there and try to change the xml file. you'll understand then – cpt. Sparrow Nov 22 '16 at 11:56
  • there is only link of android hive sir.can u please post it again sir. – seon Nov 22 '16 at 11:58
  • http://download.androidhive.info/download?code=WPSkdrdZprHT0KLCZS3ClafgXBikGqM4r7FnNYdsdUTmlAkK6%2F2mkT0heOlNOq4U82rzqbod%2F14yU2uk5TWY4Zp%2FAYx6oiD7SKI%2FEgtUapzQUqkqcWEXX1bmw%3D%3DvqARiMEKqkqsXGbVf3vVUoffTqQcD2qfqZo – cpt. Sparrow Nov 22 '16 at 11:59
  • @seon Check out this [Link](http://stackoverflow.com/questions/36847035/align-menu-item-at-navigation-to-the-right-side-in-android) – iSrinivasan27 Nov 28 '16 at 13:07
  • @iDroid i want menu icon to right side of the left to right navigation Drawer. not the navigation Drawer that opens from right to left sir. – seon Nov 29 '16 at 04:08

2 Answers2

0

change the nav_drawer_row.xml to this:

nav_drawer_row.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:clickable="true">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="30dp"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:textSize="15dp"
        android:textStyle="bold" />

<ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_profile"
             />

</LinearLayout>
cpt. Sparrow
  • 415
  • 8
  • 22
-1

Try out this: In your xml file:

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_gravity="end"
    app:headerLayout="@layout/header"
    app:menu="@menu/drawer"
    />

in your java file:

 @Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            if (mDrawer.isDrawerOpen(Gravity.RIGHT)) {
                mDrawer.closeDrawer(Gravity.RIGHT);
            } else {
                mDrawer.openDrawer(Gravity.RIGHT);
            }
            return true;
        case R.id.action_settings:
            return true;
    }
Ram Koti
  • 2,203
  • 7
  • 26
  • 36