/drawable/start.xml
1 2 3 4 5
| <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/img1" android:duration="200" /> <item android:drawable="@drawable/img2" android:duration="100" /> </animation-list>
|
android:oneshot=”false” 表示一直播放(循环)
设置为background
1 2 3 4 5
| <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/start" />
|
启动动画
1 2
| val image = findViewById<ImageView>(R.id.image) (image.background as AnimationDrawable).start()
|