1
안드로이드에서 속도계를 만들고 싶습니다 .. 아이디어는 단지 imageView에서 두 번째 이미지를 클릭하면보기가 45도 회전합니다. 하지만 문제는 두 번째 이미지 뷰 주위에 회전 점을 해결 .... 하나가 회전의 중심을 설정하는안드로이드의 속도계
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;
}
}
});
}
}