RtlNavigationView

Additional

Language
Java
Version
N/A
Created
Aug 5, 2017
Updated
Nov 8, 2019 (Retired)
Owner
Mostafa (MostafaNasiri)
Contributor
Mostafa (MostafaNasiri)
1
Activity
Badge
Generate
Download
Source code

Advertisement

RtlNavigationView (This library is no longer maintained)

RtlNavigationView is an extension of Android support library's NavigationView which enables you to have an Rtl NavigationView which is especially useful in apps that are in Right-To-Left languages like Persian.

How to Use

Add this line of code in your dependencies:

compile 'ir.basalam.rtlnavigationview:rtl-navigationview:1.3'

Define your items in a menu resource file. For example I have a menu file called activity_main_drawer.xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
        <item
            android:id="@+id/nav_camera"
            android:icon="@drawable/ic_menu_camera"
            android:title="دوربین" />
        <item
            android:id="@+id/nav_gallery"
            android:icon="@drawable/ic_menu_gallery"
            android:title="گالری" />
        <item
            android:id="@+id/nav_slideshow"
            android:icon="@drawable/ic_menu_slideshow"
            android:title="اسلایدشو" />
        <item
            android:id="@+id/nav_manage"
            android:icon="@drawable/ic_menu_manage"
            android:title="مدیریت" />

        <item android:title="ارتباطات">
            <menu>
                <item
                    android:id="@+id/nav_share"
                    android:icon="@drawable/ic_menu_share"
                    android:title="به اشتراک گذاری" />
                <item
                    android:id="@+id/nav_send"
                    android:icon="@drawable/ic_menu_send"
                    android:title="ارسال" />
            </menu>
        </item>
</menu>

Then add RtlNavigationView to your layout and pass your menu file to it like the example below:

<ir.basalam.rtlnavigationview.RtlNavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:fitsSystemWindows="true"
        app:rtl_menu="@menu/activity_main_drawer"/>

If you don't know how to handle NavigationView item clicks you can check the sample app source code.