java - Rotate object by 360 degrees with different Images in Android? -


i creating android app rotate image of car 360 degrees. want rotate object different image files of same object (eg car)

here example want implement in app.

is possible use different images in rotating object in android?

is there api or class available this?

here android code -

import android.os.bundle; import android.app.activity; import android.view.menu;  import android.app.activity; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.matrix; import android.os.bundle; import android.view.motionevent; import android.view.view; import android.view.view.ontouchlistener; import android.widget.imageview; public class mainactivity extends activity implements ontouchlistener {  private imageview dialer; private float y=0; public boolean ontouch(view v, motionevent event) {     double r=math.atan2(event.getx()-dialer.getwidth()/2, dialer.getheight()/2-event.gety());     int rotation=(int)math.todegrees(r);     switch (event.getaction()) {         case motionevent.action_down:             break;         case motionevent.action_move:             //x=event.getx();             y=event.gety();             updaterotation(rotation);             break;         case motionevent.action_up:             break;     }//switch             return true;  }//ontouch private void updaterotation(double rot){     float newrot=new float(rot);     bitmap bitmap=bitmapfactory.decoderesource(getresources(),r.drawable.round_button_big);     matrix matrix=new matrix();     matrix.postrotate(newrot,bitmap.getwidth()/2,bitmap.getheight()/2);     if(y>250){         bitmap redrawnbitmap=bitmap.createbitmap(bitmap,0,0,bitmap.getwidth(),bitmap.getheight(),matrix,true);         dialer.setimagebitmap(redrawnbitmap);     }     else{         bitmap redrawnbitmap=bitmap.createbitmap(bitmap,0,0,bitmap.getwidth(),bitmap.getheight(),matrix,true);         dialer.setimagebitmap(redrawnbitmap);     } } @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     dialer = (imageview) findviewbyid(r.id.imageview1);     dialer.setontouchlistener(this);     }//oncreate  } 

if have x amount of pictures different angles of car, have listen ontouch when want change imageview.

i advice use levellistdrawable , use setimagelevel smoothly walk through them.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -