gpt4 book ai didi

RTL 中的 android:gravity ="start"将文本左对齐而不是右对齐

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:01:54 30 4
gpt4 key购买 nike

在使用 RTL 语言(阿拉伯语)的设备上测试我的布局时,我发现带有 gravity:start 的 TextView 始终将文本对齐到左侧而不是右侧!我试过 android:textAlignment="viewStart"并且它工作正常但是由于 API 要求我不依赖它。

我的代码(我的意思是我代码中的第一个 TextView ):

<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
>

<TextView
android:text="Size"
android:gravity="start"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>

<LinearLayout android:gravity="center" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView
android:text="000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="subtext"/>
</LinearLayout></LinearLayout>

最佳答案

要获得完全支持或 RTL,您必须以 api 17 为目标

If you are targeting your app to Android 4.2 (the app'stargetSdkVersion or minSdkVersion is 17 or higher), then you shoulduse “start” and “end” instead of “left” and “right”. For example

Native RTL support in Android 4.2

关于RTL 中的 android:gravity ="start"将文本左对齐而不是右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36996493/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com