Android graphics: How does TransitionDrawable work?


  1. soBinary

    soBinary Member

    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);
    }

    Advertisement
    :
Loading...

Share This Page