Is it possible to preview the RTL view for layouts in XML Preview on Android Studio?
Asked
Active
Viewed 3,489 times
8

Paebbels
- 15,573
- 13
- 70
- 139

Eshack Nazir
- 354
- 3
- 16
2 Answers
16
For preview you can set your xml parent view with android:layoutDirection="rtl"
For example,
item.xml
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="true"
android:layoutDirection="rtl"
>
//design
</android.support.v7.widget.CardView>
android:layoutDirection="rtl"
Output :

Nabeel K
- 5,938
- 11
- 38
- 68

Magesh Pandian
- 8,789
- 12
- 45
- 60
-
7For preview only you can use tools package. (tools:layoutDirection="rtl") – TheLibrarian Aug 13 '18 at 12:07
-
1you should use tools package instead because `android:` will change the layout direction not only in preview but also in the app. – M.kazem Akhgary Dec 17 '18 at 10:12
0
An easier solution to preview RTL would be to Force RTL from Developers Options.

TheScriptan
- 189
- 1
- 9