androidandroid-studionon-english

How i can make the whole android app text from the left to right?


i am creating an android app, my phone language in Arabic and i do not want to change that, but i am building the app for left to right users, is there a setting i can put that when i debug on my personal phone to recognizes to debug from left to right opposite to my phone language?

i am thinking about using an simulator but i do not want to deal with the slowness of the android studio


Solution

  • You can always design it in LTR and it won't change. If it changes you could do this to force LTR your application.

    => You can add this to your manifest

    android:supportsRtl="false"
    

    => You can even add it to your application theme in the res/styles.

      <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorPrimary</item>
        <item name="android:screenOrientation">portrait</item>
    
        <!-- your ltr theme -->
        <item name="android:layoutDirection">ltr</item>
    </style>
    

    => The last way is to add it programmatically in your activity.

    //Java
    getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
    
    //Kotlin 
    window.decorView.layoutDirection = View.LAYOUT_DIRECTION_LTR