Android below 4.2 how to set layoutDirection to be RTL

后端 未结 3 902
情话喂你
情话喂你 2021-02-02 00:30

trying to set the layout elements to be RTL ordered

in 4.2 and above the line: layoutDirection=\"rtl\" and in the manifest: android:supportsRtl=\"true

相关标签:
3条回答
  • 2021-02-02 00:42

    Just use ViewCompat using android.support.v4.view to do it.

    ViewCompat.setLayoutDirection(findViewById(R.id.my_view), ViewCompat.LAYOUT_DIRECTION_RTL);
    
    0 讨论(0)
  • 2021-02-02 00:44

    You won't be able to. It was added to in API Level 17 which is 4.2 so the older versions do not support it.

    0 讨论(0)
  • 2021-02-02 00:58

    you can change your application language and solve this problem :

    String languageToLoad  = "en";
    Locale locale = new Locale(languageToLoad);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
    getBaseContext().getResources().getDisplayMetrics());
    
    0 讨论(0)
提交回复
热议问题