我正在尝试做从右到左的文本方向,但我得到了意想不到的结果(不像我做 html css 时的结果)。这是我为该 TextView 编写的代码:
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="96dp"
android:gravity="right"
android:text="@string/welcomeMsg"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white"
android:textDirection="rtl"
android:textSize="@dimen/welcomeMsgSize" />
我相信我已经做了该做的一切。也许我忘记了什么或者不知道。我对android很陌生。图片显示了上面的输出 这里的问题是 TextView 中文本前面的空格,也发布了文本。提前感谢您的帮助:)
最佳答案
您应该根据需要将 Textview 引力从“居中”更改为“右”或“左”。 Gravity 将为您的文本设置重力,因此请更改它。并且还将文本对齐方式从居中更改为向右或向左。
关于android textview 文本方向现在响应变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17739757/