0
我可以對指向屏幕中心的圖像進行評分。但它旋轉的半徑很大,部分擋住了屏幕。如何設置半徑像說100像素。如何設置旋轉動畫的半徑
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
screenWidthPixel = displaymetrics.widthPixels;
screenHeightPixel = displaymetrics.heightPixels;
center_x = screenWidthPixel/2;
center_y = screenHeightPixel/2;
//RotateAnimation rotate = new RotateAnimation(0, 360, Animation.ABSOLUTE, center_x, Animation.ABSOLUTE, center_y);
RotateAnimation rotate = new RotateAnimation(0, 360, center_x, center_y);
rotate.setDuration(2000);
rotate.setRepeatCount(Animation.INFINITE);
rotate.setInterpolator(new LinearInterpolator());
ImageView image= (ImageView) findViewById(R.id.test_img);
image.setAnimation(rotate);
我看起來像rotate.setRadius(100)
在這裏,IMG將自身在旋轉的中心,如果我把機器人:layout_centerInParent = 「真」 我想在img以100px的半徑爲中心旋轉屏幕的中心點 – Abhijit