倒塌时,动画的expandablelistview的童车/扩展 [英] animating the childs of an expandablelistview when collapsing/expanding

查看:94
本文介绍了倒塌时,动画的expandablelistview的童车/扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在expandablelistview动画我的孩子的意见。我想子视图展开一个组,然后从底部滑动折叠组时到顶部时,向下滑动上下。我已经看了几个方法(在动画的ViewGroup或子视图),但似乎没有很好地工作或我不这样做是正确的。

I'm trying to animate my child views in an expandablelistview. I would like the child view to slide down from top to bottom when expanding a group and sliding from bottom to top when collapsing a group. I've looked at several methods (animating the viewgroup or the child views) but none seem to work very well or I'm not doing it right.

我从BaseExpandableListAdapter扩展一个类来创建自己的自定义适配器。我也有定制(XML)的意见的团体/孩子的,我吹在getChildView和getGroupView方法。

I've extended a class from BaseExpandableListAdapter to create my own custom adapter. I also have custom (xml) views for the groups/childs which I inflate in the getChildView and getGroupView methods.

我只想当前崩溃/扩展群以动画它的孩子。任何人都可以点我在正确的方向?如果您需要了解更多信息或code,请让我知道!

I would only like the current collapsed/expanded group to animate it's child. Can anyone point me in the right direction? If you need more information or code please let me know!

问候, 伊沃

推荐答案

所以,我所做的就是用常规列表视图,然后单击动画时,该行的看法。

So what I've done is to use a regular listview and then animate the row views when clicked.

我用这个梅索德动画: Android的动画下拉/向上观点正确

I use this methode for animation: Android animate drop down/up view proper

它可以是一个有点棘手,如果高度的观点被掉下来的WRAP_CONTENT,对于这个问题我必须找到并设置高度之前,我开始动画:

It can be a bit tricky if the height for the view to be dropped down is wrap_content, for this problem I had to find and set the height before I start the animation:

public static void setHeightForWrapContent(Activity activity, View view) {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

    int screenWidth = metrics.widthPixels;

    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    int widthMeasureSpec = MeasureSpec.makeMeasureSpec(screenWidth, MeasureSpec.EXACTLY);

    view.measure(widthMeasureSpec, heightMeasureSpec);
    int height = view.getMeasuredHeight();
    view.getLayoutParams().height = height;
}

视图应消失的动画开始前再发时可见动画开始。

The view should be gone before the animation start and then made visible when animation starts.

编辑:我这里做了一个完整的例子

I made a complete example here.

这篇关于倒塌时,动画的expandablelistview的童车/扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆