Android – How to change the icons direction for menu items(DrawerLayout)?

How I can change item direction menu?

I need to change the icons direction to RTL instead of LTR, I use Gravity and Layout_Gravity but don’t work .

What can I do ? Below is my XML :

enter image description here

menu_start.xml :

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group android:checkableBehavior="single">
        <item
            android:id="@+id/nav_home"
            android:icon="@drawable/circle"
            android:title="@string/Search" />
        <item
            android:id="@+id/nav_example_item_1"
            android:icon="@drawable/circle"
            android:title="Example Item #1" />
    </group>

    <item android:title="Sub items">
        <menu>
            <item
                android:id="@+id/nav_example_sub_item_1"
                android:title="Example Sub Item #1" />
        </menu>
    </item>

</menu>

activity_start.xml :

<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"
    android:layout_gravity="right"
    android:fitsSystemWindows="true">

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

        <LinearLayout
            android:id="@+id/KeepToolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!-- We use a Toolbar so that our drawer can be displayed
                 in front of the action bar -->
            <android.support.v7.widget.Toolbar
                android:id="@+id/my_awesome_toolbar_Start"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/ORANGE_700">

                <ImageView
                    android:id="@+id/drawer_indicator"
                    android:layout_width="30dp"
                    android:layout_height="30dp" />
            </android.support.v7.widget.Toolbar>

            <!-- The rest of your content view -->

        </LinearLayout>


        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@+id/KeepToolbar"
            android:orientation="vertical">

            <ViewFlipper
                android:id="@+id/viewflipper"
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:autoStart="true"
                android:background="@color/ORANGE_700"
                android:inAnimation="@anim/right_in"
                android:outAnimation="@anim/left_out">

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

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

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

            <android.support.v7.widget.RecyclerView

                android:id="@+id/cardList"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:dividerHeight="1dp"
                android:scrollbarDefaultDelayBeforeFade="5000"
                android:scrollbarFadeDuration="5000"
                android:scrollbars="vertical" />
        </LinearLayout>
    </RelativeLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@drawable/background_color"
        app:headerLayout="@layout/header_drawer"
        app:menu="@menu/menu_start" />

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


Source: xml

Leave a Reply