首先在res目录下的drawable目录下新建一个xml文件,根节点为animaltion-list 子节点为item 代码如下
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@mipmap/q1" android:duration="150"/> <item android:drawable="@mipmap/q2" android:duration="150"/> <item android:drawable="@mipmap/q3" android:duration="150"/> <item android:drawable="@mipmap/q4" android:duration="150"/> <item android:drawable="@mipmap/q5" android:duration="150"/> <item android:drawable="@mipmap/q6" android:duration="150"/> <item android:drawable="@mipmap/q7" android:duration="150"/> <item android:drawable="@mipmap/q8" android:duration="150"/> <item android:drawable="@mipmap/q9" android:duration="150"/> <item android:drawable="@mipmap/q10" android:duration="150"/> <item android:drawable="@mipmap/q11" android:duration="150"/> <item android:drawable="@mipmap/q12" android:duration="150"/> <item android:drawable="@mipmap/q13" android:duration="150"/> <item android:drawable="@mipmap/q14" android:duration="150"/> <item android:drawable="@mipmap/q15" android:duration="150"/> <item android:drawable="@mipmap/q16" android:duration="150"/> </animation-list>
其中drawable为每一帧的图片素材,duration为每一帧持续的时间
然后在MainActivity中 调用如下代码
image = (ImageView) findViewById(R.id.frame_image); image.setBackgroundResource(R.drawable.frame); AnimationDrawable anim = (AnimationDrawable) image.getBackground(); anim.start();
在主布局中方一个ImagVIew就可以了
看效果
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦