我有一个带有视图的GestureListener。我想根据GestureListener结果更改视图可见性。双击显示视图,单击即可隐藏它。我希望在我将手指放在显示屏上时显示出来的想法(类似功能)。
mDetector = new GestureDetectorCompat(this, this);
mDetector.setOnDoubleTapListener(this);
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
mDetector.onTouchEvent(event);
return true;
}
});
这是我的手势听众..双击它会显示我的视图,但它会保持视图可见
@Override
public boolean onSingleTapUp(MotionEvent event) {
Log.d(DEBUG_TAG, "onSingleTapUp: " + event.toString());
text.setVisibility(View.INVISIBLE);
return true;
}
@Override
public boolean onDoubleTap(MotionEvent event) {
Log.d(DEBUG_TAG, "onDoubleTap: " + event.toString());
text.setVisibility(View.VISIBLE);
return true;
}
答案 0 :(得分:0)
我有类似的问题,我添加了
ImageView imgView11 =(ImageView)findViewById(R.id.imagek11d);
就在imgView11.setVisibility(View.INVISIBLE)之前;
之前和imgView11.setVisibility(View.VISIBLE);