When I switch my app language between EN and AR (during runtime) the views behave correctly by moving from the LTR to the RTL but when I start stressing the app by switching languages many times the layout direction become missy and I get RTL elements when the app is supposed to show LTR elements. Sometimes the layout direction is not refreshed anymore.
As workaround I have to set the layout direction programmatically for those views. binding.spinner.setLayoutDirection(LocaleUtil.isRtl(this) ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
Do you have any idea please ? I am trying to avoid this kind of workaround :( If it is possible to rely entirely on the Android UI rendering.
make sure that supportsRtl="true"
I can't imagine a user who will switch language many times and then returning to app on every change :)
But, anyway, if Android is not able to recreate your activities correctly you always can do it manually by setting "android:configChanges" in AndroidManifest.xml for your activities and then listening for onConfigurationChanged(Configuration newConfig) method in such activities:
In AndroidManifest.xml:
In Activity for which you set android:configChanges: