1. Check out our companion app, Forums for Android! Download from Google Play

button animate

Discussion in 'Application Development' started by chhoda, Oct 14, 2009.

  1. chhoda

    chhoda New Member
    Thread Starter
    5

    Oct 14, 2009
    2
    0
    5
    Hi all,

    I need to align a few buttons in rows and columns fornat and animate them in a jumbled way !

    I am a starter in android, it seems in layout i am unable to align the buttons to their vertical edges and horizontal edges as i want.

    need i use a tablelayout ? if yes, if i move a button from row 2 col 1 to row 1 col 2, just changing the positions will help ?

    CH
     

    Advertisement

  2. chhoda

    chhoda New Member
    Thread Starter
    5

    Oct 14, 2009
    2
    0
    5
    i wrote this piece of code

    private void exchangeButtons(Button btn1, Button btn2) {
    // Create the animation set

    AnimationSet exchangeAnimation = new AnimationSet(true);
    TranslateAnimation translate = new TranslateAnimation( Animation.ABSOLUTE, btn1.getLeft(),
    Animation.ABSOLUTE, btn2.getLeft(),
    Animation.ABSOLUTE, btn1.getRight(),
    Animation.ABSOLUTE, btn2.getRight()
    );
    translate.setDuration(500);
    exchangeAnimation.addAnimation(translate);
    int fromX = btn1.getLeft();
    int fromY = btn1.getRight();
    int toX = btn2.getLeft();
    int toY = btn2.getRight();

    System.out.println("view1 pos:" + btn1.getLeft() + ", " +btn1.getRight() + "view2 pos:" + btn2.getLeft() + ", " + btn2.getRight());

    btn1.startAnimation(exchangeAnimation);
    }

    while debugging

    i saw fromX = 160, fromY = 240, toX = 240 toY = 320

    the first view just disappears for 200ms and appears. I want to actually swap the both 2 buttons' position.
     

Share This Page

Loading...