Android Studio XML 中的 RTL 预览

8
在Android Studio的XML预览中,是否有可能预览RTL布局视图?
2个回答

16

为了预览,您可以使用 android:layoutDirection="rtl" 设置您的 xml 父视图。

例如:

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"

输出:

输入图像说明


7
仅供预览时,您可以使用工具包。 (tools:layoutDirection =“rtl”) - TheLibrarian
1
你应该使用工具包而不是 android:,因为这样做会改变布局方向,不仅在预览中,还会影响应用程序。 - M.kazem Akhgary

0
一个更简单的预览RTL的解决方案是从开发者选项中强制启用RTL。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接