Nobody have tried this kind of thing ?
I found this post 
http://www.mail-archive.com/[email protected]/msg49872.html

but it seems the AbsoluteLayout is deprecated. Please suggest to make
it work in latest sdk

regards
Jagat

On Nov 6, 5:28 pm, Jags <[email protected]> wrote:
> I am trying toswapthe position of two buttons.
> my swapping code looks as below.
>
> private void exchangeButtons(Buttonbtn1,Buttonbtn2) {
>         // Create the animation set
>
>         AnimationSet exchangeAnimation = new AnimationSet(true);
>         TranslateAnimation translate = new TranslateAnimation(
> Animation.RELATIVE_TO_SELF, btn2.getLeft(),
>                                                                               
>                                           Animation.RELATIVE_TO_SELF, 
> btn1.getLeft(),
>                                                                               
>                                           Animation.RELATIVE_TO_SELF, 
> btn2.getRight(),
>                                                                               
>                                           Animation.RELATIVE_TO_SELF, 
> btn1.getRight()
>         );
>         translate.setDuration(500);
>         exchangeAnimation.addAnimation(translate);
> //      int fromX = btn1.getLeft();
> //      int fromY = btn1.getRight();
> //      int toX = btn2.getLeft();
> //      int toY = btn2.getRight();
>
>         Log.d("ArrangeMe", "view1 pos:" + btn1.getLeft() + ", "
> +btn1.getRight() + "view2 pos:" + btn2.getLeft() + ", " + btn2.getRight
> ());
>
>         AnimationSet exchangeAnimation1 = new AnimationSet(true);
>         TranslateAnimation translate1 = new TranslateAnimation(
> Animation.RELATIVE_TO_SELF, btn1.getLeft(),
>                                                                               
>                                           Animation.RELATIVE_TO_SELF, 
> btn2.getLeft(),
>                                                                               
>                                           Animation.RELATIVE_TO_SELF, 
> btn1.getRight(),
>                                                                               
>                                           Animation.RELATIVE_TO_SELF, 
> btn2.getRight()
>         );
>                 translate1.setDuration(500);
>                 exchangeAnimation1.addAnimation(translate1);
>
>                 // EXECUTE
>                 btn1.startAnimation(exchangeAnimation);
>                 btn2.startAnimation(exchangeAnimation1);
>
>     }
>
> I call the code as below
>
> exchangeButtons(button1, button2);
>
> my layout looks as below
>
> <LinearLayout android:layout_width="fill_parent"
> android:layout_height="wrap_content" android:orientation="horizontal">
> <Buttonandroid:text="One" android:id="@+id/button1"
> android:layout_height="70px" android:layout_width="70px"
> android:layout_weight="1"></Button>
> <Buttonandroid:text="Two" android:id="@+id/button2"
> android:layout_height="70px" android:layout_width="70px"
> android:layout_weight="1"></Button>
> </LinearLayout>
>
> what happens when i execute the code is,
>
> instead of the buttons exchanging their positions, they just disappear
> for sometime[may be 500 ms] and reappear as they were originally.
>
> how to resolve this problem ? will it work properly in device ?
>
> regards

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to