亲爱的android高手,请问如何让ImageView在 move 的时候旋转。我有飞机的照片。当我 touch_down 并随之 move 时,ImageView 会跟随我的手指并动态旋转。当我向上触摸手指时,平面 ImageView 向上旋转,当我向左触摸时,ImageView 动态向左旋转。请你能给我指路吗?我正在寻找一些示例,并且只能使用屏幕上的固定点,而不是 move 物体。我正在处理示例,例如示例 Calculate angle of touched point and rotate it in Android .但是我有 move 的物体,你能帮忙吗?![画出我需要的东西 - 动态跟随手指并旋转它][1]
最佳答案
试试这个,
public class abc extends Activity implements OnTouchListener
{
ImageView img;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.one);
img = (ImageView) findViewById(R.id.imageView1);
img.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
{
// Here u can write code which is executed after the user touch on the screen
break;
}
case MotionEvent.ACTION_UP:
{
// Here u can write code which is executed after the user release the touch on the screen
break;
}
case MotionEvent.ACTION_MOVE:
{
// Here u can write code which is executed when user move the finger on the screen
break;
}
}
return true;
}
还要检查这个链接, http://obviam.net/index.php/moving-images-on-the-screen-with-androi/
关于android - 在Android中使用ImageView move 时如何使ImageView跟随我的手指旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12378808/