Managing Layout Direction in Jetpack Compose
I have recently been on the path of learning Jetpack Compose for Android Development. It's excellent to see that UI implementation in Android has evolved.
Problem
I'm developing an application named Private. It's a simple Privacy application that uses Jetpack Compose as UI and MVVM as Architecture. for the Password section, I needed to have a Dialog. The application, for now, is just LTR and doesn't support RTL so like in the old days I set supportRtl
to false
in the Manifest and expect that the application gonna shown in the LTR direction.
But in devices with the RTL languages when a Dialog appears, Everything is RTL and then changes to LTR and unfortunately, the whole transition is visible! So what is the solution?
Solution
I've solved this problem with CompositionLocalProvider
and LocalLayoutDirection
, It's simple:
With this, You can manage Layout Direction with Logic and Provide the best functionality as Users deserve.
Good Luck.