我想在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>
答案 0 :(得分:0)
以编程方式使用,而不是来自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中使用单行。