我需要移動EditText
隨着觸摸。移動EditText隨着觸摸android
這裏是我的代碼:
editText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
float touchY = event.getY();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, (int) touchY, 0, 0);
editText.setLayoutParams(lp);
return true;
}
});
它的工作,並與觸摸一起移動EditText
但問題是EditText
開始閃爍。意思是以很高的速度上下移動。 我怎樣才能阻止它,並像平滑一樣移動它?