【开源】transitions-everywhere
transitions-everywhere
- https://github.com/andkulikov/transitions-everywhere
介绍:
android4.4和5.0中Transitions API的兼容补丁,可兼容2.2+运行效果:
![]()
使用说明:
关于Transitions API请看这篇文章Transitions API from Android KitKat and Lollipop。
在原本需要使用android.transition.*的地方使用android.transitions.everywhere.*。
如果你想在xml文件中使用transition,不要将xml放在res/anim,而是放在res/transition目录。同时你需要使用将命名空间改为app 而不是android,下面是例子:
|
1
2
3
4
5
6
7
8
9
|
<transitionSet xmlns:app="http://schemas.android.com/apk/res-auto" app:duration="400"> <changeBounds/> <fade app:fadingMode="fade_in"> <targets> <target app:targetId="@id/transition_title"/> </targets> </fade></transitionSet> |
解决setTransitionName方法的兼容问题
android5.0中View类提供了setTransitionName()方法,用本库同样可以实现相同功能,只是在用法上稍微有点区别:
|
1
|
TransitionManager.setTransitionName(View v, String transitionName) |
在2.2 2.3版本中使用本库看不到动画效果,但是变换依然可以正确执行。
最后,在eclipse上编译的时候需要5.0的sdk(因为要用到Build.VERSION_CODES.LOLLIPOP这样的代码判断版本),但运行环境不依赖于5.0.
posted on 2015-04-08 09:54 wasdchenhao 阅读(413) 评论(0) 收藏 举报

浙公网安备 33010602011771号