how to change supportsRtl value inside the app

时间:2017-03-02 23:45:25

标签: android

as i know if we set android:supportsRtl="true" in manifest the app will change it's direction based on default language of the phone ..my problem is that lot's of people in my country set their default language to English whereas they know a little about English an if they open app and see the application language is English they will definetly remove the app .. so my question is is there any way to change the value inside the app . and i give them the option to change language at the beggening of the app or in setting .. ty

1 个答案:

答案 0 :(得分:1)

您可以使用以下代码为应用设置语言,这是英语,用您的语言替换en

         Locale locale = new Locale("en"); 
         Locale.setDefault(locale);
         Configuration config = new Configuration();
         config.locale = locale;
         getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
清单文件中的

android:configChanges="locale"

您可以随时让他们选择语言,但请记住除当前活动外所有活动语言都有变化,您必须重新开始当前活动。