4

I want to marquee text, and when the marquee completes (the 1 full marquee cycle), I want to trigger another event. Is there a good way to do this? I haven't seen an OnEnd or similar function when marquee-ing a textview

RyanInBinary
  • 1,533
  • 3
  • 19
  • 47

1 Answers1

1

using a custom TextView, you can override onDraw to use reflection on mMarquee field and on mStatus field of the mMarquee field (see TextView code on grepcode or such).

mStatus value is 2 when marquee is running, and 0 when stopped.

onDraw is called a lot, but in particular, it is called right after the marquee is completed.

njzk2
  • 38,969
  • 7
  • 69
  • 107
  • How can you get this mMarquee field? I have seen https://android.googlesource.com/platform/frameworks/base/+/jb-mr0-release/core/java/android/widget/TextView.java but I don't know how to get it work – Pablo R. Apr 15 '19 at 12:07
  • hi @njzk2. Can you share example on how to use reflection on getting mMarquee. I am having issue getting this field or inherited fields. Thanks – donmj Nov 27 '20 at 03:40
  • 1
    @donmj see https://www.baeldung.com/java-reflection-class-fields to get started on reflection – njzk2 Nov 27 '20 at 07:59