Skip to content

Instantly share code, notes, and snippets.

@matthewmorrone
Created October 29, 2020 07:39
Show Gist options
  • Save matthewmorrone/066c8b1f8ec271c08226f26f70925aac to your computer and use it in GitHub Desktop.
Save matthewmorrone/066c8b1f8ec271c08226f26f70925aac to your computer and use it in GitHub Desktop.
attempt to prevent outside touch from dismissing
wordbar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
System.out.println(view+" "+motionEvent);
if (motionEvent.getX() < 0 || motionEvent.getX() > popupWindow.getWidth()) return true;
if (motionEvent.getY() < 0 || motionEvent.getY() > popupWindow.getHeight()) return true;
return false;
// final int X = (int)event.getRawX();
// final int Y = (int)event.getRawY();
// switch (event.getAction() & MotionEvent.ACTION_MASK) {
// case MotionEvent.ACTION_DOWN:
// RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
// // _xDelta = X - lParams.leftMargin;
// // _yDelta = Y - lParams.topMargin;
// break;
// case MotionEvent.ACTION_UP:
// break;
// case MotionEvent.ACTION_POINTER_DOWN:
// break;
// case MotionEvent.ACTION_POINTER_UP:
// break;
// case MotionEvent.ACTION_MOVE:
// RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)view.getLayoutParams();
// layoutParams.leftMargin = X;
// layoutParams.topMargin = Y;
// // layoutParams.rightMargin = -250;
// // layoutParams.bottomMargin = -250;
// view.setLayoutParams(layoutParams);
// break;
// }
// return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment