RTL support Android multilanguage

Android RTL Support (Right to Left) Multi language App

Android have RTL support for multi language app. If your app does support multiple language like english, hindi, arbic, urdu etc where some language script write in Right to Left Direction. So you have to add RTL support(Right to Left) on android app for wide range of users from different regions which truely requires the feature of Android Multi Language Support.

In this Android Tutorial, You will be learn How to make an App which do support English and Arabic Languages. If user will choose English language the App alignment will be Left to Right. If he/she chooses Arabic Then the App alignment will be Right To Left. You have to use Android Shared Preferences to store User Language Choice so that the app retains whatever Language we’ve selected even after leaving the app and coming back again. So lets begin this exciting tutorial on Android RTL Support for Multi Language App.

Android RTL Support Multi Language

Login & Download source code


android course


1) Store User’s Language Choice
2) Set App Local Language
3) Add RTL Support on Layout

Store User’s Language Preference

First thing you need to do is create a share preference to store language selection. Now add two button for language on layout for example I added two button name as English and Arabic. Now on button click listener store value in share preference.

   ll_english.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                SharedPreferenceUtils.getInstance().saveString(Constant.LANGUAGE, Constant.ENGLISH);
               // here start next Activity
        ll_Arabic.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                SharedPreferenceUtils.getInstance().saveString(Constant.LANGUAGE, Constant.ARABIC);
               // here start next Activity

Set App Local

Now Create a folder name as value-ar (ar for arabic ) inside res folder . You can create value folder for other language too but remember to use initial letter on each value folder. Please check language support link. Copy string.xml file from default value folder and paste it inside this new folder. Now just covert the value of each string into corresponding language but don’t change the string id name. The string id name must be same otherwise system will displace default language only. for example-

   <string name="password">Password</string>
    <string name="forgot_password_login">Forgot Password?</string>
    <string name="password">كلمه السر</string>
    <string name="forgot_password_login">هل نسيت كلمة المرور؟</string>

Once you convert all the string value into another language then its time to set app local using java code. create on function on App launcher activity so that way whenever the app start it will get language preference from Share preference and will set app local on each launch. You need to pass language initial to this function. for example english – “en”, arabic – “ar”,french -“fr” etc.

public static void setApplicationlanguage(String language) {

        Resources res = MyApp.getContext().getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();

            conf.setLocale(new Locale(language)); // API 17+ only.
        } else {
            conf.locale = new Locale(language);
        res.updateConfiguration(conf, dm);

Add RTL Support on Layout

Till so far you did all the task for language conversion only. Now you need to add Right to Left support on app that means text gravity will be right, navigation drawer will be on right side etc. first add the supportrtl =true on androidmanifest file.

<manifest ... >
    <application ...

Now on all layout filed change all the left with start and right with end. So when app local will change the android OS auto change the layout display too. to get more details about android multi language support see official link.

Attribute supporting LTR only	Attribute supporting LTR and RTL
android:gravity="left"	        android:gravity="start"
android:gravity="right"	        android:gravity="end"
android:layout_gravity="left"	android:layout_gravity="start"
android:layout_gravity="right"	android:layout_gravity="end"
android:paddingLeft	        android:paddingStart
android:paddingRight	        android:paddingEnd
android:drawableLeft	        android:drawableStart
android:drawableRight	        android:drawableEnd
android:layout_alignLeft	android:layout_alignStart
android:layout_alignRight	android:layout_alignEnd
android:layout_marginLeft	android:layout_marginStart
android:layout_marginRight	android:layout_marginEnd
android:layout_alignParentLeft	android:layout_alignParentStart
android:layout_alignParentRight	android:layout_alignParentEnd
android:layout_toLeftOf	android:layout_toStartOf
android:layout_toRightOf	android:layout_toEndOf

If you want more specific design change when user change the language then create another layout folder name as language-(init. letter of language). Please see below structure.

        main.xml This layout file is loaded by default.
        main.xml This layout file is loaded for Arabic text.
        main.xml This layout file is loaded only for non-Arabic
                 languages that use an RTL text direction.

Remember Toolbar title name won’t change after user change the language. To solve this problem you need to set toolbar title string name from activity.


If you have any other question you can ask me.

android course

Do you want payment gateway integration?

Instamojo Payment Gateway
How to Integrate Paytm Payment gateway

Posted in andorid and tagged , , , , , .

I Am Post Graduation (M.Tech. C.S.E) from VNIT, Nagpur. I Have Published Two Research Paper On International Journal. My Apps on Google Play Store- Sanyukt Parivar(Mp Police ), NOTOtag- Digital Chhindwara, The Tubby-VoiceRecognizer & More.
Contact me at kamal.bunkar@blueappsoftware.in

Leave a Reply

Your email address will not be published. Required fields are marked *