Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中设置文本方向_Android - Fatal编程技术网

如何在android中设置文本方向

如何在android中设置文本方向,android,Android,我有一个文本视图,我在其中设置了波斯语/阿拉伯语文本,并将重力设置为右侧,但在平板电脑中,它将文本显示为左侧。如果将重力设置为左侧,则将其显示为右侧。在它成为真值之前,我该怎么做 <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="fill_

我有一个文本视图,我在其中设置了波斯语/阿拉伯语文本,并将重力设置为右侧,但在平板电脑中,它将文本显示为左侧。如果将重力设置为左侧,则将其显示为右侧。在它成为真值之前,我该怎么做

<LinearLayout android:layout_width="fill_parent"
              android:layout_height="wrap_content"
            >
<TextView android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:id="@+id/manage_account_id_textview"
          android:text="فارسي"
          android:gravity="right"
          />
</LinearLayout>

你喜欢这样吗

<LinearLayout android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                >

    <RelativeLayout android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                >

    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/manage_account_id_textview"
              android:text="فارسي"
              android:layout_alignParentRight="true"
              />
    </RelativeLayout>

</LinearLayout>

尝试使用

 manage_account_id_textview.setTextDirection(View.TEXT_DIRECTION_RTL);

 manage_account_id_textview.setTextDirection(View.TEXT_DIRECTION_ANY_RTL);