androidでonTouchListener()を使ってimageviewを指で動かしたい……
xml を作成しました -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/rel_slide"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_dark" >
<ImageView
android:id="@+id/img_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"/>"
</RelativeLayout>
</RelativeLayout>
アクティビティ ファイルで、この imageView に onTouchListener を実装しました: img_arrow
コードは次のとおりです。
((ImageView) findViewById(R.id.img_arrow)).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
switch (arg1.getAction()) {
case MotionEvent.ACTION_MOVE:
LayoutParams layoutParams = (LayoutParams)v.getLayoutParams();
layoutParams.leftMargin=(int)arg1.getX();
layoutParams.topMargin=(int)arg1.getY();
v.setLayoutParams(layoutParams);
break;
}
return true;
}
});
しかし、これにより、一度に2つ表示されるimageViewのちらつきが発生するのは、 ACTION_MOVEが呼び出されたときにlayoutParamsが非常に高速に設定されたためである可能性があります.....plz help