https://kotlinlang.org logo
#compose
Title
# compose
k

Kort

01/19/2021, 8:50 AM
Hi guys, I have a problem regarding RTL. I've googled, but I couln't find the similar issues. While dealing with Arabic, if I call
Text("تزامن...")
in
AmbientLayoutDirection
as
Ltr
, there will be an extra wrap line (see picture below). But it stays normal while as
Rtl
. Anyone have any solutions or suggestions? Thanks in advance!
Copy code
Providers(AmbientLayoutDirection provides LayoutDirection.Ltr) {  
 Text("LTR")  
 Text("تزامن...")  
 Text("مزيد من المعلومات.")  
}  
Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {  
 Text("RTL")  
 Text("تزامن...")  
 Text("مزيد من المعلومات.")  
}
j

Julius

01/19/2021, 8:55 AM
have you tried using
Copy code
modifier = Modifier.fillMaxWidth()
for the text?
k

Kort

01/19/2021, 9:01 AM
Yes, it works. Yet, under some circumstances, I need to use
wrapContent
.
s

Siyamed

01/20/2021, 6:16 AM
For your info, where to align the RTL language by default required a lot of discussions, and I am still not sure what the default behavior should be. WE still have the
TextDirection.Content
,
TextDirection.ContentOrLtr
configuration options where you can ask the system to align the text to RTL when the text is RTL.
android dance 1
That will change the behavior of Text to align RTL text to right even if layout direction is LTR (as far as I remember, not sure if it would require the code that Julius mentioned)
k

Kort

01/20/2021, 8:58 AM
@Siyamed Thank you for providing this option, that totally solve the issue once and for all!
6 Views