TheUnreal
TheUnreal

Reputation: 24492

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

Upvotes: 4

Views: 7887

Answers (4)

Lins Louis
Lins Louis

Reputation: 2643

This will automatically adjust according to the device locale

android:textDirection="locale"

Upvotes: 0

TheUnreal
TheUnreal

Reputation: 24492

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.

Upvotes: 5

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

RTL layout support feature is supported on Android 4.2(API level 17) or above only . Please Add android:layout_gravity="left/right" in your parent Layout . And also allow android:textAlignment.

Set minSdkVersion=17

Please read http://developer.android.com/reference/android/view/View.html#attr_android:layoutDirection

Upvotes: 2

Malwinder Singh
Malwinder Singh

Reputation: 7070

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.

Upvotes: 3

Related Questions