Note that there are some explanatory texts on larger screens.

plurals
  1. POFrame Animation not working in Android 2.2
    text
    copied!<p>I am making a android project which includes a Frame Animation. My Animation works fine in 4.0 but it doesnt show in 2.2. Is there any way i could get it work in 2.2/2.3? Any working code snippet for 2.2 would be great.</p> <p>Can post my code if needed.</p> <p><strong>EDIT :</strong> Here is my working code</p> <pre><code>public class FrameAnimationExample extends Activity { AnimationDrawable animation; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btnStart = (Button) findViewById(R.id.btnStart); final ImageView imgView = (ImageView)findViewById(R.id.img); btnStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startAnimation(); } }); imgView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); } class Starter implements Runnable { public void run() { animation.start(); } } private void startAnimation(){ animation = new AnimationDrawable(); animation.addFrame(getResources().getDrawable(R.drawable.hud_bubble_fill_line), 100); animation.addFrame(getResources().getDrawable(R.drawable.hud_bubble_fill), 100); animation.addFrame(getResources().getDrawable(R.drawable.medal_brown), 100); animation.addFrame(getResources().getDrawable(R.drawable.medal_silver), 100); animation.addFrame(getResources().getDrawable(R.drawable.medal_gold), 100); animation.setOneShot(true); ImageView imageView = (ImageView) findViewById(R.id.img); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(80, 90); params.alignWithParent = true; params.addRule(RelativeLayout.CENTER_IN_PARENT); imageView.setLayoutParams(params); imageView.setImageDrawable(animation); imageView.post(new Starter()); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload