Changing the direction of the RTL LTR layout

It seems that the layout direction of all GUI elements is now controlled by the system language. When it is from right to left, all menus, dialogs, message boxes, etc. Appear from right to left. It's horrible.

The application has a built-in localization function ("select a country). How to make localization of an application control the graphical interface of the application, and not the system language of the device?

+5
source share
1 answer

There is a long way ahead of you. You will need to define the device settings in your Application class, and then put in place certain locales and layouts in the code. Then you need to process onConfigurationChanged for each action to handle the 'changedirection \ locale' change the configuration event and process it yourself, reloading your actions so that they select new changes at runtime to get the right resources from the layout folder on the fly without closing and not opening the application. Honestly, this is a bad trip, especially part of a reboot activity that will lead to some weird behavior and errors. But in the end it is possible.

Check this out for more information:

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

+1
source

Source: https://habr.com/ru/post/1238974/


All Articles