その非常に簡単なことは、私は前にそれを行っているが、私は予想通り、今のが実行されていません。 imageview.setOnTouchListener(this);
onTouch与える奇妙なタッチポイント私がやっているのAndroid
シナリオ:: を私は今、私はこのようtouchlistener
を設定し、ImageView
が置かれているRelativeLayout
を持っているものを簡単に説明しましょう
このように私は私のイメージを移動しています、それは ...私がやったonTouch(View v,MotionEvent event)
機能を無効にするために私に尋ねたとAction_Move
に私はXとYを取得し、余白を残してトップにそれらを追加します。
奇妙な問題: マイImageView
であることが見えるように非常に顕著な揺れで、私は正しい方向に向かっていた場合と同様に、ImageView
が右側に移動しますが、その途中でそれが左側に戻ってくる移動画像が安定していないように、その...私は私がlog
中に取得XとYを与えている..そのような何かを振動させる、これはあなたのアイデアを与える願っています。 RelativeLayoutのため
ACTION_DOWN[#0(pid 0)=160,233] Going right..
ACTION_MOVE[#0(pid 0)=160,233] ////
ACTION_MOVE[#0(pid 0)=160,233] //
ACTION_MOVE[#0(pid 0)=174,231] //
ACTION_MOVE[#0(pid 0)=176,233] //
ACTION_MOVE[#0(pid 0)=196,232] //
ACTION_MOVE[#0(pid 0)=152,232] // suddenly i got 152 as location for x... image comes back
ACTION_MOVE[#0(pid 0)=167,232] // again started to go right
ACTION_MOVE[#0(pid 0)=180,233] // going right
ACTION_MOVE[#0(pid 0)=173,233] // again comes a little back
ACTION_MOVE[#0(pid 0)=187,232] // same thing goes till end..
ACTION_MOVE[#0(pid 0)=159,232]
ACTION_MOVE[#0(pid 0)=174,231]
ACTION_MOVE[#0(pid 0)=177,233]
ACTION_MOVE[#0(pid 0)=189,231]
ACTION_MOVE[#0(pid 0)=155,232]
ACTION_MOVE[#0(pid 0)=171,231]
ACTION_MOVE[#0(pid 0)=183,230]
ACTION_MOVE[#0(pid 0)=161,234]
ACTION_MOVE[#0(pid 0)=171,233]
ACTION_MOVE[#0(pid 0)=174,230]
ACTION_MOVE[#0(pid 0)=183,230]
ACTION_MOVE[#0(pid 0)=162,234]
ACTION_MOVE[#0(pid 0)=170,233]
ACTION_MOVE[#0(pid 0)=176,233]
ACTION_MOVE[#0(pid 0)=165,233]
ACTION_MOVE[#0(pid 0)=175,232]
ACTION_MOVE[#0(pid 0)=163,233]
ACTION_MOVE[#0(pid 0)=171,233]
ACTION_MOVE[#0(pid 0)=167,233]
ACTION_MOVE[#0(pid 0)=172,232]
ACTION_MOVE[#0(pid 0)=178,232]
ACTION_MOVE[#0(pid 0)=158,234]
ACTION_MOVE[#0(pid 0)=170,234]
ACTION_MOVE[#0(pid 0)=170,232]
ACTION_MOVE[#0(pid 0)=177,231]
ACTION_MOVE[#0(pid 0)=157,234]
ACTION_MOVE[#0(pid 0)=160,234]
ACTION_MOVE[#0(pid 0)=169,232]
ACTION_MOVE[#0(pid 0)=165,233]
ACTION_MOVE[#0(pid 0)=167,233]
ACTION_MOVE[#0(pid 0)=159,233]
ACTION_UP [#0(pid 0)=161,233]
XMLコード:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#99000000">
<ImageView
android:id="@+id/imageview"
android:layout_width="400dp"
android:layout_height="400dp"
android:layout_marginLeft="100dp"
android:layout_marginTop="100dp"
android:scaleType="matrix" />
</RelativeLayout>
ので、これは最高です、私はあなたが何を必要とする場合、まだ、私に知らせて、私の質問を説明することができました。
更新::そのコンテナすなわちRelativeLayout
にImageView
を移動するための コード:onTouch
で
case MotionEvent.ACTION_MOVE:
LayoutParams params = (LayoutParams) imageview.getLayoutParams();
params.leftMargin = params.leftMargin + x;
params.topMargin = params.topMargin + y;
imageview.setLayoutParams(params);
break;
「各移動アクションは、別の移動アクションを起こし、わずかに異なるOnTouchEventを発生させます - この再帰はあなたに与えられる 『振動』効果を。」それを少し説明してください、リンク/ドキュメントは、それが詳細に書かれているところで非常に役に立つでしょう... – Farhan