【发布时间】:2018-01-30 09:11:01
【问题描述】:
是否可以在 Android Studio 的 XML Preview 中预览布局的 RTL 视图?
【问题讨论】:
标签: xml android-studio preview right-to-left
是否可以在 Android Studio 的 XML Preview 中预览布局的 RTL 视图?
【问题讨论】:
标签: xml android-studio preview right-to-left
对于预览,您可以使用 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"
输出:
【讨论】:
android:不仅会在预览中改变布局方向,还会在应用程序中改变布局方向。