Android Image rotation -


i want image rotate indefinite time........which means want loop it. attempt unfortunately not work. suggestions?

package com.android.test;  import android.app.activity; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.matrix; import android.graphics.drawable.bitmapdrawable; import android.os.bundle; import android.widget.imageview; import android.view.viewgroup.layoutparams; import android.widget.linearlayout; import android.widget.imageview.scaletype;  public class imagerotate extends activity {  int x=1;  int y=3;       @override      public void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);          linearlayout linearlayout = new linearlayout(this);           while (y==3) {    bitmap bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.icon);     int width = bitmap.getwidth();    int height = bitmap.getheight();     matrix matrix = new matrix();    matrix.postrotate(x);     bitmap rotatedbitmap = bitmap.createbitmap(bitmap, 0, 0, width,height, matrix, true);    bitmapdrawable bmd = new bitmapdrawable(rotatedbitmap);     imageview imageview = new imageview(this);    imageview.setimagedrawable(bmd);    imageview.setscaletype(scaletype.center);     linearlayout.addview(imageview, new linearlayout.layoutparams(      layoutparams.fill_parent, layoutparams.fill_parent));    setcontentview(linearlayout);     x+=1;    }      }  } 

you can't loop in main thread. make app unresponsive. consider using rotateanimation - see link documentation.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -