This question already has an answer here:
- Marquee text in Android 15 answers
I have tried to use marquee and its not working here is my code, please let me know where im going wrong
<TextView
android:text="lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00"
android:id="@+id/TextView02"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:inputType="text"
android:maxLines="1">
</TextView>
i am using android SDK 2.0.1
I had gone through this situation where textview marquee was not working. However follow this and I am sure it will work. :)
and programmatically add these 2 lines...
tvMarquee.setSelected(true) is required incase if any one of the view is already focused and setSelected will make it work. No need to use.
it is deprecated and above codes works.
I have created a custom class AlwaysMarqueTextView
And you can startMarquee when desire.. like
Yes, marquee_forever also work in case of fixed width for TextView. (e.g. android:layout_width="120dp")
Must required attributes are:
Working code:
These attributes must be included in the
textview
tag in order to allow scrolling.Everything else is optional.
I'm working with minSDK=14 and was curious what set of these variations would work. I ended up with:
in addition to other formatting stuff. I didn't need scrollHoriontally, focusable, or focusableInTouchMode.
This set did require a call to
What I find interesting is that singleLine has allegedly been deprecated, with a recommendation to replace it with maxLines = 1. Except - when I do that, that change alone stops the text from scrolling. One would hope that when singleLine eventually bites the dust, that all its current behavior will be triggered by maxLines...
are the only required attributes and scrolling even works with
layout_weight
defined withlayout_width=0dp
here is some sample code:
But what is most important is implicitely or explicitely
TextView
should get selected.You can do this with: