在res/drawable下面新建一個stylr.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <transition xmlns:Android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/badtz1"/>
- <item android:drawable="@drawable/badtz2"/>
- </transition>
- public class Draw01Activity extends Activity {
- /** Called when the activity is first created. */
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- Resources res = getResources();
- TransitionDrawable transition = (TransitionDrawable) res.getDrawable(R.drawable.stylr);
- ImageView mImageView = (ImageView) findViewById(R.id.imageView1);
- mImageView.setImageDrawable(transition);
- //2秒開始轉換
- transition.startTransition(2000);
- }