【问题标题】:RTL Preview on Android Studio XMLAndroid Studio XML 上的 RTL 预览
【发布时间】:2018-01-30 09:11:01
【问题描述】:

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

【问题讨论】:

    标签: xml android-studio preview right-to-left


    【解决方案1】:

    对于预览,您可以使用 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"

    输出:

    【讨论】:

    • 仅供预览,您可以使用工具包。 (工具:layoutDirection="rtl")
    • 你应该使用工具包,因为android:不仅会在预览中改变布局方向,还会在应用程序中改变布局方向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-28
    • 1970-01-01
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    相关资源
    最近更新 更多