Android App을 만들어 자동차 이미지를 360도 회전시킵니다. 같은 개체 (예 : 자동차)의 다른 이미지 파일로 개체를 회전하고 싶습니다.Android에서 다양한 이미지로 360도 회전 할 수 있나요?
여기 내 앱에 구현하려는 Example입니다.
Android에서 오브젝트 회전시 다른 이미지를 사용할 수 있습니까?
사용할 수있는 API 또는 클래스가 있습니까?
여기 내 안드로이드 코드 - 당신이 이미지 뷰를 변경하고자 할 때 당신이 차의 다른 각도에서 사진의 X 금액이있는 경우
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
}
openGL 예제를 사용해보십시오. 그러나 자동차의 3D 모델이 필요합니다. –
ok Lalith B, 시도해 보겠습니다. – Deepu
@deepu 해결책을 찾았습니까? –