Created
November 24, 2019 10:42
-
-
Save Audhil/0c51a8c204e2cd5fa40dc93b315ee188 to your computer and use it in GitHub Desktop.
to increase touch area of a view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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