1

アンドロイドの専門家の皆様へ移動時にImageViewを回転させる方法をお聞きしたいと思います。飛行機の写真があります。touch_downして一緒に移動すると、ImageViewは私の指に追従し、動的に回転します。指を上にタッチすると、平面ImageViewが上に回転し、左にタッチすると、ImageViewが動的に左に回転します。道を教えてくれませんか?私はいくつかの例を探していましたが、移動するオブジェクトではなく、画面上の固定点でのみ作業できました。タッチポイントの角度を計算し、Androidで回転させる例などの例を使用していました。しかし、私は動く物体を持っています、あなたは助けることができますか?![私が必要とするものを想像してください-動的に指をたどってそれを回転させてください] [1]

4

1 に答える 1

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/

于 2012-09-12T05:12:05.753 に答える