我按照Android开发者网站上的指示在应用程序中添加GIF图像。但是该图像未显示为动画,而是像普通图像一样显示。
可在drawable文件夹下创建一个名为animated_image.xml的XML文件,其中包含以下内容:Animation in drawable
可在drawable文件夹下创建一个名为animated_image.xml的XML文件,其中包含以下内容:Animation in 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="@drawable/los01" android:duration="50" />
<item android:drawable="@drawable/los02" android:duration="50" />
</animation-list>
编码
layout.setBackgroundResource(R.drawable.bg);
img.setBackgroundResource(R.drawable.mylosanim);
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
frameAnimation.start();
tv1.setText("Sorry!!!Play Again!!!");
tv3.setText("Your Level-1 Score:"+Integer.toString(score));
layout.setClickable(true);
frameAnimation.stop();