'How to check if the device uses the right-to-left direction using Jetpack Compose?
On Android we can use android determine if device is in right to left language/layout.
But does Jetpack Compose provide any API to check the layout direction? Without interacting with the resources or other Android APIs.
Solution 1:[1]
We can use LocalLayoutDirection
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
) {
if (LocalLayoutDirection.current == LayoutDirection.Rtl) {
Text("RTL")
} else {
Text("LTR")
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Raed Mughaus |