tags:

views:

114

answers:

0

Hi,

I was wondering if it is possible to display a gif animation on an image button. I followed the example on Android API BitmapDecode sample and can now display animated gifs on the canvas.

Is it possible to display this same gif on an imagebutton. I tried using the setBackgroundDrawable() and setImageDrawable() but it gives me an empty button.

@Override
 public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
  setContentView(R.layout.test);
  ImageButton btn = (ImageButton) findViewById(R.id.ImageButton01);
  SampleView p=new SampleView(this);

  p.setDrawingCacheEnabled(true);
  p.buildDrawingCache();
      btn.setBackgroundDrawable(p.getBackground());

}

The SampleView() class is similar to the one provided in the BitmapDecode sample (i have removed all other code snippets and it now displays only gif animation)

Thanks, New Guy.