I need to force my application to run RTL regardless the phone language it can be done by Developer mode and i need it be added programatically to the application to force the application display to rtl
android:supportsRtl="true"
this working depend on phone languages Thanks
To force right-to-left layouts on your Android device you need to open Settings, and access the Developer options menu (if developer options aren't enabled, here's how to do it). Once you've accessed the menu, scroll down to find the “Force RTL layout direction” tab. Tap on it to activate the option, and you're done.
Change all of your app's "left/right" layout properties to new "start/end" equivalents. If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use “start” and “end” instead of “left” and “right”.
A layout direction can be left-to-right (LTR) or right-to-left (RTL). It can also be inherited (from a parent) or deduced from the default language script of a locale.
Set the language of your app on startup like :
Resources res = getResources();
Configuration newConfig = new Configuration( res.getConfiguration() );
Locale locale = new Locale( appLanguage );
newConfig.locale = locale;
newConfig.setLayoutDirection( locale );
res.updateConfiguration( newConfig, null );
setLayoutDirection is important in case your appLanguage is differ from the Phone language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With