开发者

Having trouble animating a "drop down"

I have a LinearLayout that contains two other LinearLayouts, oriented vertically.

The top inner LinearLayout is always visible; the bottom inner LinearLayout is sometimes visible.

There a view on the top inner LinearLayout the user can press to make the bottom LinearLayout show. However, I would like the bottom LinearLayout to "drop down" out of the top LinearLayout.

I'm having some real trouble doing this. Ideally, I'd like to make it look like it was dropping out from under the top LinearLayout (meaning not only does the bottom of the LinearLayout slide out from the top, but all the controls appear开发者_如何学Go to as well), but I'm having trouble even getting the dimensions of the LinearLayout to animate (read: grow).

Any suggestions?


I'm assuming you're using the Animation class. What you could do is anchor the dropdown LinearLayout to the bottom of the first using android:layout_AlignParentBottom = "true" in your xml. Then in your anim folder put something like:

<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0.0"
android:toXScale="1.0"
android:duration="whatever (in milliseconds)"
android:interpolator="@android:anim/linear_interpolator"
/>

name it dropdownanim

Then set that animation to the view at a certain time.

private Animation mAnimation; 

mAnimation = AnimationUtils.loadAnimation(this, R.anim.dropdownanim);
linearlayoutview.startAnimation(mAnimation); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜