Search code examples
androidtextviewmarquee

how to android textview marquee getDuration?


I have time many try TextView marquee animation scroll need marquee animation duration, finish Listener plz help me...

  1. marquee scroll time
  2. marquee scroll finish point or interface listener

Solution

  • You can create animation and animation time like this in anim res/anim/marquee.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate
            android:fromXDelta="100%"
            android:toXDelta="-100%"
            android:duration="10000"
            android:repeatCount="infinite"
            android:repeatMode="restart"
            android:interpolator="@android:anim/linear_interpolator"/>
    </set>
    

    and call it where you are using your textView

     TextView myTextView = (TextView) findViewById(R.id.myTextView);
     Animation marquee = AnimationUtils.loadAnimation(this, R.anim.marquee);
     myTextView.startAnimation(marquee);