Android 判断是否是Rtl


 第一种方法:

private boolean isRtl() {
return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
}


第二种方法:

/**
* Check to see if the current layout is Right-to-Left. This check is only
* supported for API 17+. For earlier versions, this method will just return
* false.
*
* NOTE: This is based on the private API method in {@link View} class.
*
* @return boolean Boolean indicating whether the currently locale is RTL.
*/
@SuppressLint("NewApi")
public boolean isLayoutRtl(View view) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
return View.LAYOUT_DIRECTION_RTL == view.getLayoutDirection();
} else {
return false;
}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM