我想在android中制作速度计..想法在imageView上只是简单点击第二个imageView将旋转45度。但问题是第二个imageView不能在固定点周围旋转....任何人都可以建议我做什么
public class BloodPressureActivity extends Activity {
ImageButton btnImgBoy;
ImageView imgVNeddleBoy;
private int currentAngle = 0;
private int numOfAngle = 7;
Animation anim, zoomAnim;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blood_pressure);
btnImgBoy = (ImageButton) findViewById(R.id.imageButtonBollenBoy);
imgVNeddleBoy = (ImageView) findViewById(R.id.imageViewNeddlBoy);
anim = AnimationUtils.loadAnimation(this, R.anim.back_rotation);
zoomAnim = AnimationUtils.loadAnimation(this, R.anim.zoom_anim);
// anim.setFillAfter(true);
btnImgBoy.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// rotate image view neddle
btnImgBoy.startAnimation(zoomAnim);
currentAngle++;
currentAngle = currentAngle % numOfAngle;
switch (currentAngle) {
case 0:
imgVNeddleBoy.setRotation(45);
break;
case 1:
imgVNeddleBoy.setRotation(90);
break;
case 2:
imgVNeddleBoy.setRotation(135);
break;
case 3:
imgVNeddleBoy.setRotation(180);
break;
case 4:
imgVNeddleBoy.setRotation(225);
break;
case 5:
imgVNeddleBoy.setRotation(270);
break;
case 6:
imgVNeddleBoy.setRotation(315);
imgVNeddleBoy.startAnimation(anim);
break;
}
}
});
}
}