Android Studio XML上的RTL预览

Esh*_*zir 5 xml preview right-to-left android-studio

是否可以在Android Studio的XML预览中预览布局的RTL视图?

Mag*_*ian 9

对于预览,您可以将xml父视图layoutDirection设置为"rtl"

例如,

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>
Run Code Online (Sandbox Code Playgroud)

安卓的layoutDirection = "RTL"

输出:

在此输入图像描述

  • 仅用于预览,您可以使用工具包。(tools:layoutDirection =“ rtl”) (5认同)