fhucho wrote:
> I have a LinearLayout, with a text and a button, which I want to show
> and hide (using translate animation) sometimes. As for now I show/hide
> it by setVisibility() to View.GONE or View.VISIBLE. To set the
> translate animation I do this:
> 
> myLinearLayout.setLayoutAnimation(new LayoutAnimationController
> (myTranslateAnimation));

"A layout animation controller is used to animated a layout's, or a view
group's, children. Each child uses the same animation but for every one
of them, the animation starts at a different time."

http://developer.android.com/reference/android/view/animation/LayoutAnimationController.html

> But when I call myLinearLayout.setVisibility(View.VISIBLE),
> myLinearLayout shows imediately but without the text and the button.
> The text then slides to the linearlayout and then the button does the
> same.

That is the effect that a LayoutAnimationController provides.

> When I call setVisibility next time there is no animation at all.

"Sets the layout animation controller used to animate the group's
children after the first layout."

http://developer.android.com/reference/android/view/ViewGroup.html#setLayoutAnimation(android.view.animation.LayoutAnimationController)

Hence, using setLayoutAnimation() will only achieve a one-time
animation, per the documentation.

It is unclear what effect you really are aiming for based on your
description. Consider using a SlidingDrawer if that fits your UI, as
that avoids having to mess around with animations yourself. Otherwise,
you probably want to use animations directly, rather than via animation
controllers. There are examples of this in the SDK ApiDemos IIRC, and
here is an example from one of my books:

http://github.com/commonsguy/cw-advandroid/tree/master/Animation/SlidingPanel/

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 1.0 In Print!

--~--~---------~--~----~------------~-------~--~----~
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