how prevent the android application layout from change it's direction when change the language of mobile.
without using layoutDirection ltr or rtl .
In the manifest file, in the Application tag you can specify if the RTL is supported or not
<application
android:supportsRtl="false">
you can find more information here https://developer.android.com/guide/topics/manifest/application-element.html
call this method on onResume method :
public void SetLocale(Context context) {
Locale.setDefault(new Locale("en"));
Configuration conf = context.getResources().getConfiguration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
conf.setLayoutDirection(new Locale("en"));
}
context.getResources().updateConfiguration(conf,
context.getResources().getDisplayMetrics());
}
layoutDirection? It's designed exactly for when you want to control layout direction. - Ted Hopp