• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android graphics: How does TransitionDrawable work?

soBinary

Lurker
Jun 25, 2011
5
0
I read the documentation but I can't manage to make a transition occur. What's the flow of events supposed to be like? Who calls who?

Suppose I wanted to have an activity call init() to draw line a, and call go to make a 5 second transition to line b. What would I have to do to this code?


public class Fun extends View
{
Drawable a;
Drawable b;
TransitionDrawable t;
public Fun(Context context)
{
super(context);
a = new LineA();
b = new LineB();
Drawable ray[] = {a,b};
t = new TransitionDrawable( ray );
}

@Override
protected void onDraw(Canvas canvas)
{
t.draw(canvas);

}

public void init()
{
t.resetTransition();
}

public void go()
{
t.startTransition(5000);
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones