开发者

Animate Child View in ExpandableList

开发者 https://www.devze.com 2023-03-29 11:37 出处:网络
I only have 1 chi开发者_StackOverflowld view for each group view, which is inflated from a layout .xml file. I wish to animate the child view so that when the child item is displayed, the list item be

I only have 1 chi开发者_StackOverflowld view for each group view, which is inflated from a layout .xml file. I wish to animate the child view so that when the child item is displayed, the list item below it slides down. I tries this with a number of animations, but the isse is that the height/ width of the child view is first made visible and then the view animates within that space. However, I want a child view to show between 2 list views by making the following group view slide down to make way for the chile view.

For exanple, I tried the following. The animation does happens, but not as I have described above. I have added the following to the getChildView(), just before I return the child view:

    Animation anim = AnimationUtils.loadAnimation(MyExpandableList.this,
                                                   R.anim.translate);
    v.setAnimation(anim);

Here's is my translate.xml:

    <?xml version="1.0" encoding="utf-8"?>
       <translate xmlns:android="http://schemas.android.com/apk/res/android" 
            android:fromYDelta="-50%p" 
    android:toYDelta="0"
    android:duration="500"/>

Thanks for your help.

Ani.


You have to animate all child views below the currently added child view also. Add all the Aniamtions to an AnimationSet and start the set.

0

精彩评论

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