LoginSignup
0

More than 1 year has passed since last update.

TextViewでRtL言語も強制的にLtR方向に表示する

Posted at

はじめに

RtLの言語の文字が入っているTextViewにより大きくレイアウトが崩れてしまったため、強制的にLtR方向になるように指定したい。
RtL言語へのローカライズ対応予定がないため今回は強制的にLtRにしたが、多言語対応の面ではレイアウトをRtLに対応させた方が良い

修正

xmlにて以下のようにandroid:textDirection="ltr"指定すると強制的にLtR方向に指定できる

activity_main.xml
    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:textSize="14sp"
        android:textStyle="bold"
        android:textDirection="ltr"
        />

textDirectionには言語の方向指示に依存しつつ、デフォルトの方向を指定するContentOrLtrなどもある

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0