2017-02-21 79 views
0

如何防止android應用程序佈局在改變移動語言時改變方向。防止佈局方向發生變化

不使用layoutDirection ltr或rtl。

+0

爲什麼不使用'layoutDirection'?它的設計正好是您想要控制佈局方向的時候。 –

回答

0

更多信息,在您的應用程序定義,您可以添加:

android:supportsRtl="false" 

*請注意,這僅在API 17中受支持,並且默認爲false。

0

通話的onResume方法,這個方法:

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()); 

    }