Skip to content

Instantly share code, notes, and snippets.

@Audhil
Created November 24, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Audhil/0c51a8c204e2cd5fa40dc93b315ee188 to your computer and use it in GitHub Desktop.
Save Audhil/0c51a8c204e2cd5fa40dc93b315ee188 to your computer and use it in GitHub Desktop.
to increase touch area of a view
@Bind(R.id.baseLayout)
RelativeLayout baseLayout;
@Bind(R.id.button)
Button delegate;
private void init() {
baseLayout.post(new Runnable() {
@Override
public void run() {
Rect delegateArea = new Rect();
delegate.getHitRect(delegateArea);
System.out.println("audhil:top : " + delegateArea.top);
System.out.println("audhil:bottom : " + delegateArea.bottom);
System.out.println("audhil:right : " + delegateArea.right);
System.out.println("audhil:left : " + delegateArea.left);
delegateArea.top -= 200;
System.out.println("audhil:after : top : " + delegateArea.top);
TouchDelegate expandedArea = new TouchDelegate(delegateArea, delegate);
// if (View.class.isInstance(delegate.getParent())) { // working fine
if (delegate.getParent() instanceof View) {
System.out.println("audhil:bomb!");
((View) delegate.getParent()).setTouchDelegate(expandedArea);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment