1
我正在开发android应用程序。当用户在布局中触摸并拖动图像时,我需要旋转整个布局。我正在使用相对布局。在这我有一个图像视图和拖动按钮和一个图像作为相对布局的背景。现在我需要在拖动按钮移动时旋转整个相对布局。如何在Android中旋转整个相对布局
使用旋转动画进行尝试时,在触摸事件未感应后立即运行。我添加了我的代码如下
anim = new RotateAnimation(0, -15f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f);
anim.setInterpolator(new LinearInterpolator());
anim.setDuration(700);
anim.setFillAfter(true);
anim.setAnimationListener(MainActivity.this);
rotationctrl.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
innerlayout.startAnimation(anim);
}
else if (event.getAction() == MotionEvent.ACTION_MOVE) {
} else if (event.getAction() == MotionEvent.ACTION_UP) {
}
return true;
}
});
这是什么问题。我犯了错误..请帮助我。
你是什么意思,“它运行后,该触摸事件不感应” – blessenm
当我触摸图像,布局是旋转的,但当我再次触摸图像,触摸事件没有听。 – deepa