第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在 Android 中多次播放動(dòng)畫 drawable?

如何在 Android 中多次播放動(dòng)畫 drawable?

繁星淼淼 2023-06-08 19:14:10
我有一個(gè)來自 png 和 android:oneshot="true" 的可繪制動(dòng)畫,因?yàn)槲也幌M麆?dòng)畫不斷播放,但只有在我激活它時(shí)才播放。問題是它只播放一次,當(dāng)我嘗試時(shí)myAnimation.play();它不會(huì)再次播放。我試過myAnimation.stop();并再次播放,但它使動(dòng)畫在動(dòng)畫結(jié)束前停止。當(dāng)我用 開始動(dòng)畫時(shí),也會(huì)發(fā)生同樣的事情myAnimation.run();,盡管我不知道其中的區(qū)別。//in onCreate() methodimageView = findViewById(R.id.imageView);imageView.setBackgroundResource(R.drawable.animation_drawable);myAnimation = (AnimationDrawable) imageView.getBackground();//Triggers in somewhere else in a threadmyAnimation.start();//animation_drawable.xml<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/animation_drawable" android:oneshot="true">    <item android:drawable="@drawable/kapali" android:duration="0"/>    <item android:drawable="@drawable/acik" android:duration="500"/>    <item android:drawable="@drawable/kapali" android:duration="0"/></animation-list>
查看完整描述

1 回答

?
絕地?zé)o雙

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊

animation_drawable.xml您擁有的中android:oneshot="true",刪除它或?qū)⑵涓臑?code>false.

嘗試使用

myAnimation.setOneShot(false);

在 start() 方法之前。

當(dāng)你想停止動(dòng)畫使用

myAnimation.stop();

對(duì)于您的情況,在停止動(dòng)畫(或設(shè)置 oneshot=true)后,要重新啟動(dòng)動(dòng)畫,請(qǐng)使用

myAnimation.setVisible(/*visible=*/true,/*restart=*/true);
查看完整回答
反對(duì) 回復(fù) 2023-06-08
  • 1 回答
  • 0 關(guān)注
  • 123 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)