Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Right to Left ListView

I've been trying to make a ListView to work as RTL (Right to Left). I've added the following line in the ListView and LinearLayout properties:

android:layoutDirection="rtl"

and it still shows the list from left to right.

Any ideas?

enter image description here

like image 264
TheUnreal Avatar asked Dec 25 '22 15:12

TheUnreal


2 Answers

Thank you all but I solved it with:

android:textDirection="rtl"

I've added it to the ListView and the layouts, and it worked. Next time you should try considering using this too for RTL layouts.

like image 141
TheUnreal Avatar answered Dec 27 '22 03:12

TheUnreal


To take advantage of RTL layout mirroring, simply make the following changes to your app:

Declare in your app manifest that your app supports RTL mirroring. Specifically, add android:supportsRtl="true" to the <application> element in your manifest file.

Change all of your app's left/right layout properties to new start/end equivalents.

  • If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use start and end instead of left and right. For example, android:paddingLeft should become android:paddingStart.

  • If you want your app to work with versions earlier than Android 4.2
    (the app's targetSdkVersion or minSdkVersion is 16 or less), then you should add start and end in addition to left and right. For
    example, you’d use both android:paddingLeft and android:paddingStart.

like image 44
Malwinder Singh Avatar answered Dec 27 '22 03:12

Malwinder Singh