Question

I want to apply Marquee on Arabic Text in a TextView. Following code works fine for English text, but does not work for Arabic text. Can anyone tell me how to fix it?

<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>
Was it helpful?

Solution

use this programmatically not from xml:

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

With xml you use this :

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

use single line in your xml.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top