添加动画的ExpandableListView [英] Add animation to an ExpandableListView

查看:489
本文介绍了添加动画的ExpandableListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来打开的可扩展列表在Android中,当添加动画? 我想这样,当用户点击扩展列表上,它有一个动画/效果就像我开的滑动抽屉。

Is there a way to add animation when opening an expandable list in Android? I want it so that when the user clicks on the expandable list, it has an animation/effect like I'm opening a sliding drawer.

它移动缓慢,直到它完全打开。

It moves slow until it is completely opened.

推荐答案

我已经花了很多时间,没有运气搜索。现有的解决方案,只是不够光滑 - 如果你的布局是东西不仅仅是2个按钮比较复杂,它成为laggy

I've spent a lot of time searching with no luck. The existing solutions are just not smooth enough - if your layout is something more complex than just 2 buttons, it becomes laggy.

所以,我创建了自己的 ListAdapter 的缓存全貌成位图键,然后执行动画上缓存的视图,而不是观点本身。它的工作原理快。

So, I've created my own ListAdapter that caches the whole view into a Bitmap and then performs the animation on the cached view instead of the view itself. It works much faster.

这是: https://github.com/dmitry-zaitsev/ExpandableAdapter

好消息是,你并不需要重写一堆code - 只是包装我的 ExpandableAdapter 在你的适配器,并提供视图的ID将充当像切换按钮和视图的id持有第二级的含量:

The good news is that you don't need to rewrite a bunch of code - just wrap my ExpandableAdapter around your adapter and provide the id of the view that will act like a toggle button and the id of the view that holds the content of the second level:

new ExpandableAdapter(context, yourAdapter, R.id.switch, R.id.holder);

这就是一切。

And that is all.

这篇关于添加动画的ExpandableListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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