Created
July 18, 2021 09:10
-
-
Save L-Briand/045418aa9d2d256702b1dcabbbd1b172 to your computer and use it in GitHub Desktop.
Android View.isLeftToRight()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val View.isLeftToRight: Boolean | |
@SuppressLint("SwitchIntDef") | |
get() = when (ViewCompat.getLayoutDirection(this)) { | |
View.LAYOUT_DIRECTION_LTR -> true | |
View.LAYOUT_DIRECTION_RTL -> false | |
View.LAYOUT_DIRECTION_INHERIT -> (parent as? View)?.isLeftToRight ?: true | |
View.LAYOUT_DIRECTION_LOCALE -> TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_LTR | |
else -> throw IllegalStateException() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment