【问题标题】:android textview text direction now responding to changesandroid textview 文本方向现在响应更改
【发布时间】:2013-07-18 08:46:09
【问题描述】:

我正在尝试从右到左的文本方向,但我得到了意想不到的结果(不像我做 html css 时的结果)。这是我对该文本视图的代码:

<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" />

我相信我做了所有该做的事。也许我忘记了什么或者不知道。我对安卓很陌生。图片显示了上面的输出这里的问题是textview中文本之前的空格并且也发布了文本。提前感谢您的帮助:)

【问题讨论】:

    标签: android xml styles


    【解决方案1】:

    您应该根据需要将 Textview 重力从“中心”更改为“右”或“左”。 重力将为您的文本设置重力,因此请更改它。并将文本对齐方式从中心更改为向右或向左。

    【讨论】:

    • 我在文档中看到的内容没有左右之分。developer.android.com/reference/android/view/…
    • 只需将此属性放在您的 TextView 中,一切都会正常运行,它会自动检测您的文本并相应地进行更改。 android:textDirection="anyRtl"
    【解决方案2】:

    android:textSize="@dimen/welcomeMsgSize" 罪魁祸首..减少你在那个文件中指定的大小..!!

    【讨论】:

    • 26dp 不算大。实际上我以后可能需要它更大。
    • 你有没有检查属性中是否设置了任何填充变量!
    • 如你在上面的xml中看到的,没有设置
    猜你喜欢
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-19
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多