views:

394

answers:

1

Imagine I have a toolbar implemented as a horizontal LinearLayout as follows:

  [___Button1____] [___Button2___] [___Button3___] [___Button4___]

When someone clicks on Button2, I want the toolbar to change to:

  [___Button1____] [___________Button2___________] [___Button3___]

The toolbar should transition from the first state to the second state through a smooth animation. I would like to use a scale animation on Button2, and while that is happening, Button3 and Button 4 should move to the right (while the animation is going on). At the end of the animation (or maybe during), I will fade Button4 out.

Question: How do I achieve an animation of the layout of the toolbar such that only one component (i.e. Button2) is being scaled while the others are not being scaled - the layout is simply updated during the animation of Button2.

I looked at LayoutAnimationController, but it does not appear to allow me to either: 1. specify different animations for the different components, OR 2. indicate that only animate one component and don't animate the others.

I can't scale the entire toolbar because that distorts Button1/3/4 which I don't want.

Any thoughts on how to do this?

A: 

Hi,

I had the same issue with the ListView, can you try adjusting my code. Though I am not sure how you are handling your button events:

public void onListItemClick(ListView l, View v, int position, long id) {

    ImageView iv = (ImageView)v.findViewById(R.id.icon);
    iv.startAnimation(anim);

}

Note in your case you will be working with the Button view and not the ImageView.

Regards

Jonas