expandableListView 的动画 [英] Animation for expandableListView

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

问题描述

是否可以为 expandableListView 应用展开或折叠动画?

Is it possible to apply an expand or collapse animation for expandableListView?

推荐答案

可以使用一个简单的 ListView 来完成,该 ListView 包含一个最初隐藏的视图和一个扩展 Animation 的自定义类.基本思想是从 View.GONE 开始,然后逐渐将边距从负值重新调整到所需的大小,同时将可见性设置为 View.VISIBLE.

It can be done using a simple ListView that contains an initially hidden view and a custom class that extends Animation. The basic idea is to start with View.GONE then gradually re-size the margin from a negative value to the required size while setting visibility to View.VISIBLE.

见:

..最后

最后一个示例包含您需要的所有代码.对我来说看起来有点hackish,特别是你必须最初设置 view.bottomMargin = -50 或更多,否则动画第一次不能正常工作,但到目前为止我没有找到任何可行的替代方案(除了将 ScrollView 与您自己的容器项而不是 ListView 一起使用).

The last example contains all the code you need. It looks a bit hackish to me, especially the fact that you must initially set view.bottomMargin = -50 or more, otherwise the animation does not work properly the first time, but so far I did not find any viable alternative (apart from using a ScrollView with your own container items instead of a ListView).

最后,这个应用程序包括上面的例子,以及许多其他有用的例子和来源链接:

And finally, this app includes the above example, among lots of other useful examples with links to sources:

更新:Google 因涉嫌侵犯知识产权而从 Play 商店中删除了该应用程序(尽管它只包含演示和开源项目的链接),作者现在可以从 http://goo.gl/ihcgs如需了解详情,请参阅 https://plus.google.com/108176685096570584154/posts.注意:我不隶属于作者.

Update: Google removed the app from play store allegedly for intellectual property violation (although it only contained demos and links to open source projects), the author now made the apk available for direct download from http://goo.gl/ihcgs For more details see https://plus.google.com/108176685096570584154/posts. NB: I'm not affiliated with the author.

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

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