android - 在Android中使用ImageView move 时如何使ImageView跟随我的手指旋转?

标签 android rotation imageview move

亲爱的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/

相关文章:

android - HttpUrlConnection.getInputStream 在 Android 中返回空流

安卓动态图像

java - 在全屏模式下绘制图像 Android

android - 从 URL 将图像设置为 ImageView

android - Horizo​​ntalScrollView与Recyclerview滑动android冲突

安卓 : how to disable the animation of switch?

android - 没有硬件 "Options"按钮,如何让选项菜单出现?

ios - 在 iOS 中旋转屏幕时如何执行某些操作?

svg - 旋转和移动 SVG 中的文本元素

ios - 如何在 tabbarcontroller 中旋转一个 View ?