Identifying RTL language in Android

前端 未结 16 1742
既然无缘
既然无缘 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:36

    Native RTL support in Android 4.2

        public static ComponentOrientation getOrientation(Locale locale) 
        {
                // A more flexible implementation would consult a ResourceBundle
                // to find the appropriate orientation.  Until pluggable locales
                // are introduced however, the flexiblity isn't really needed.
                // So we choose efficiency instead.
                String lang = locale.getLanguage();
                if( "iw".equals(lang) || "ar".equals(lang)
                    || "fa".equals(lang) || "ur".equals(lang) )
                {
                    return RIGHT_TO_LEFT;
                } else {
                    return LEFT_TO_RIGHT;
                }
        }
    

提交回复
热议问题