Identifying RTL language in Android

前端 未结 16 1758
既然无缘
既然无缘 2020-11-28 06:59

Is there a way to identify RTL (right-to-left) language, apart from testing language code against all RTL languages?

Since API 17+ allows several resources for RTL a

16条回答
  •  一个人的身影
    2020-11-28 07:33

    This will work in all SDKS:

    private boolean isRTL() {
        Locale defLocale = Locale.getDefault();
        return  Character.getDirectionality(defLocale.getDisplayName(defLocale).charAt(0)) == Character.DIRECTIONALITY_RIGHT_TO_LEFT;
    }
    

提交回复
热议问题