代码之家  ›  专栏  ›  技术社区  ›  SharjeelNisar

Android:为什么TextView上的字幕适用于英文文本,而不适用于阿拉伯文文本?

  •  0
  • SharjeelNisar  · 技术社区  · 10 年前

    我想在TextView中对阿拉伯语文本应用Marquee。以下代码适用于英语文本,但不适用于阿拉伯语文本。有人能告诉我怎么修吗?

    <TextView
                android:id="@+id/tVMessage"
                style="@style/tVMessage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textDirection="anyRtl"
                android:text="Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye" />
    
    
    <style name="tVMessage">
            <item name="android:lines">1</item>
            <item name="android:ellipsize">marquee</item>
            <item name="android:fadingEdge">horizontal</item>
            <item name="android:marqueeRepeatLimit">marquee_forever</item>
            <item name="android:scrollHorizontally">true</item>
            <item name="android:focusable">true</item>
            <item name="android:focusableInTouchMode">true</item>
            <item name="android:textColor">#ffffff</item>
        </style>
    
    1 回复  |  直到 10 年前
        1
  •  0
  •   Harshit Rathi    10 年前

    以编程方式使用,而不是从xml:

    textView.setSingleLine(true);
    textView.setEllipsize(TruncateAt.MARQUEE);
    textView.setFocusableInTouchMode(true);
    textView.setFreezesText(true);
    textView.setMarqueeRepeatLimit(-1);
    textView.setFocusable(true);
    textView.setSelected(true);
    

    对于xml,您可以使用:

    <TextView
                android:id="@+id/tVMessage"
                style="@style/tVMessage"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textDirection="anyRtl"
                android:singleLine="true"
                android:text="Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye Good bye" />
    

    在xml中使用单行。