Search code examples
androidtransition

How can I repeat a transition forever?


I have a transition looking like this:

<?xml version="1.0" encoding="UTF-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:drawable="@drawable/divider"/>
    <item android:drawable="@drawable/divider_active"/>

</transition>

and Code looking like this:

View divider = v.findViewById(R.id.divider);
if (divider != null) {
  TransitionDrawable transition = (TransitionDrawable) divider.getBackground();
  transition.startTransition(2000);
}

My problem is, I don't know how to repeat this transition forever, so I can create a pulsing effect.

Edit:

To make things clear: The code gets executed when creating a view (listitem), so loops are no solution.


Solution

  • I think you should use AnimationDrawable instead of TransitionDrawable: http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html