I am setting up a “menu expand” animation. The expanding options are 2 RelativeLayout nested in a vertical LinearLayout. The TranslateAnimation is applied to the surrounding LinearLayout and makes the options expand from the bottom.
The problem is that only the first nested RelativeLayout is displayed. The second just becomes visible without animation.
Below, the XML layout in question, the method applying the animation, and the call.
Thank you very much for your thoughts
<LinearLayout
android:id="@+id/bmb_navigation_expanded"
style="@style/bmb_RelativeLayout"
android:layout_above="@id/bmb_bottom_bar"
android:orientation="vertical"
android:visibility="gone" >
<RelativeLayout
style="@style/bmb_RelativeLayout">
option 1 stuff
</RelativeLayout>
<RelativeLayout
style="@style/bmb_RelativeLayout">
option 2 stuff
</RelativeLayout>
</LinearLayout>
Method applying the animation to the LinearLayout:
public static void setSlideIn(ViewGroup panel, Context ctx) {
AnimationSet set = new AnimationSet(false);
Animation animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(200);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0);
panel.setLayoutAnimation(controller);
}
This is how I call the animation:
layout.setVisibility(View.VISIBLE);
setSlideIn(layout, getActivity());
Answering my own question here.
LayoutAnimationControllerdistributes the animation to allViewGroupchilds. If I want to animate theViewGroupas a single entity I must do the following: