如何创建一个动态的drawable
首先得有几组图片
创建drawable
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@mipmap/audio_animation_list_left_1" android:duration="300"></item>
<item android:drawable="@mipmap/audio_animation_list_left_2" android:duration="300"></item>
<item android:drawable="@mipmap/audio_animation_list_left_3" android:duration="300"></item>
</animation-list>
运行动态图片的代码
private void play() {
if (animationView.getBackground() instanceof AnimationDrawable) {
AnimationDrawable animation = (AnimationDrawable) animationView.getBackground();
animation.start();
}
}
private void stop() {
if (animationView.getBackground() instanceof AnimationDrawable) {
AnimationDrawable animation = (AnimationDrawable) animationView.getBackground();
animation.stop();
animation.selectDrawable(2);
}
}
點擊查看更多內容
1人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦