1. Download our Official Android App: Forums for Android!

Apps Android graphics: How does TransitionDrawable work?

Discussion in 'Android Development' started by soBinary, Jun 25, 2011.

  1. soBinary

    soBinary Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    Jun 25, 2011

    Jun 25, 2011
    5
    0
    5
    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

Share This Page

Loading...