Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout direction changes RTL LTR

It appears that the layout direction of all GUI elements is now controlled by the system language. When it is a right-to-left one, all menus, dialogs, message boxes etc' appear from right to left. This is horrible.

The app has a localizing feature built in("choose your country) How can I make the app localization govern the GUI of the app rather than the devices system language ?

like image 974
user5708331 Avatar asked Nov 08 '22 23:11

user5708331


1 Answers

There is a long journey ahead of you .. you will need to detect device settings in your 'Application' class and then enforce specific locales and layout directions in code .. You will then need to handle onConfigurationChanged for every activity to handle 'layoutdirection|locale' configuration change event and handle those yourself by reloading your activities so that they pick the new runtime changes in order to fetch the correct resources from layout folder on the fly without having to close and reopen the app. To be honest, it's a buggy ride especially the reload activities part which will produce some weird behavior and bugs .. but it's doable eventually ..

Check this out for further info :

https://github.com/aleung/RunningCadence/blob/master/RunningCadence/src/leoliang/runningcadence/Application.java

https://github.com/aleung/RunningCadence/blob/master/RunningCadence/src/leoliang/runningcadence/PreferenceActivity.java

like image 165
Mohammad Zekrallah Avatar answered Nov 15 '22 12:11

Mohammad Zekrallah