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

Apps button animate

chhoda

Lurker
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
 
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.
 
Back
Top Bottom