I have a text view with following XML attributes:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dip"
android:maxLines="1"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="1"
android:textColor="@android:color/black"
android:id="@+id/ticker"
/>
I'd like to be able to set the horizontal scroll rate, making it slightly faster than the default. How do I do with this (in XML)?
Thanking you in advance.
This is my first answer on SO, so I don't have reputation so I can't comment on Mike's answer, but I modified it a little bit to make it work with Android L.
Besides that, if f.get(tv) returns null, try calling mTextView.setSelected(true) before calling setMarqueeSpeed(). This worked for me.
I don't think there's an attribute that you can set in XML for that purpose.
It might be a bit overkill for you, but check out this customized extended marquee for Android, all settings can be customized in the coding part, you need to play with setDuration of the animation to achieve the speed you want.
Just an addition to Mike's answer. Because it returns
NoSuchFieldException
when working withAppCompatActivity
:Here's how I did it, it's dirty but it gets the job done, until they wake-up and make it configurable!
Could you believe there's a "// TODO Add an option to configure this" in the Marquee private static inner class!