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