【问题标题】:Spinner direction not changed微调器方向未更改
【发布时间】:2019-06-23 19:53:12
【问题描述】:

大家好

我在将微调器方向设置为 RTl 时遇到问题。 事实上,我的代码在支持 layoutDirecton 的 api 17 和 18 中不起作用, 但它在 api 27 中完美运行。

<android.support.v7.widget.AppCompatSpinner
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_weight="1"
                android:layoutDirection="rtl" />

我搜索了互联网,发现 ViewCompat 类的使用作为一个不起作用的解决方案。

如果您能指导我,我将不胜感激

【问题讨论】:

    标签: android android-layout android-spinner right-to-left


    【解决方案1】:

    首先确保您在 AndroidManifest.xml 中启用了 rtl 支持

    <application
    ...
    android:supportsRtl="true"
    ...>
    

    之后在您的 Spinner 定义中使用它:

    android:layoutDirection="rtl"
    android:textDirection="rtl"
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    相关资源
    最近更新 更多