读书人

TransitionDrawable的运用

发布时间: 2012-11-07 09:56:10 作者: rapoo

TransitionDrawable的使用
这个SDK里面的一段代码:
比较适合来做一个简单的动画(比如文字的渐变放大效果等)

Resources res = getResources();TransitionDrawable transition = (TransitionDrawable) res.getDrawable(R.drawable.expand_collapse);ImageView image = (ImageView) findViewById(R.id.toggle_image);image.setImageDrawable(transition);//当间隔一秒后显示transition.startTransition(1000);

这个expand_collapse.xml文件放到Drawable文件夹当中:
<?xml version="1.0" encoding="utf-8"?><transition xmlns:android="http://schemas.android.com/apk/res/android">    <item android:drawable="@drawable/image_expand" /><item android:drawable="@drawable/image_collapse" /></transition>


当然在测试的时候需要准备2张图片image_expand,image_collapse

读书人网 >其他相关

热点推荐