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