android determine if device is in right to left language/layout

后端 未结 8 1947
予麋鹿
予麋鹿 2020-12-09 07:49

Is there a way to determine if the device is in a right to left language (something like Arabic) as opposed to something that\'s left to right (English)?

Something c

8条回答
  •  我在风中等你
    2020-12-09 08:29

    I think this is a better way:

    val isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR
    

    Docs:

    https://developer.android.com/reference/android/support/v4/text/TextUtilsCompat.html#getLayoutDirectionFromLocale(java.util.Locale)

    Or, if you have minAPI 17 or above, you can just use this:

    val isLeftToRight=TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())==View.LAYOUT_DIRECTION_LTR
    

    Docs:

    https://developer.android.com/reference/android/text/TextUtils.html#getLayoutDirectionFromLocale(java.util.Locale)

提交回复
热议问题