0

We are working on an App that needs to work on API19. We are supposed to show a text over a VideoView and when the text is longer (than that can be fit inside the container) we would like to scroll/marquee the text horizontally.

Though the TextView has a property to specify Marquee, we could not get it working.

Here is the XML definition:

android:visibility="invisible"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:scrollHorizontally="true"

Here is how it is made visible programmatically:

textView.setVisibility(View.VISIBLE);
textView.setSelected(true);
textView.setEnabled(true);

I even tried to set all attributes programmatically instead of XML definitions. None of the attempts worked. There are many questions on this topic, I tried almost all the suggestions, yet this could not be made to work.

Update: It works fine if I don't call textView.setText() . From this answer: https://stackoverflow.com/a/13765865/560449 it appears we can not get Marquee effect to continue working after a call to textView.setText() . Anyone know of a fix for this?

Community
  • 1
  • 1
Suresh
  • 925
  • 1
  • 9
  • 23

1 Answers1

0

Just got rid of this issue a moment back and found no Rocket science involved here!

All you need to do is just set all the attributes programatically once you have called setText() in code.

For example

mTvTitle.setText("skjdfbaskjfdbkajbgjkbgjkdbgkjg");
        mTvTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        mTvTitle.setSingleLine(true);
        mTvTitle.setMarqueeRepeatLimit(5);
        mTvTitle.setSelected(true);

Done! It's working way too better for me.

SOF REFERENCE

Community
  • 1
  • 1
sud007
  • 5,824
  • 4
  • 56
  • 63