Created
April 14, 2015 07:25
-
-
Save AizazZaidee/6317ecbb746403bec3ca to your computer and use it in GitHub Desktop.
Expand Touch Delegates of ImateView, TextView, EditText ... any View.class
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
public static void expandViewTouchDelegate(final View view, final int top, | |
final int bottom, final int left, final int right) { | |
((View) view.getParent()).post(new Runnable() { | |
@Override | |
public void run() { | |
Rect bounds = new Rect(); | |
view.setEnabled(true); | |
view.getHitRect(bounds); | |
bounds.top -= top; | |
bounds.bottom += bottom; | |
bounds.left -= left; | |
bounds.right += right; | |
TouchDelegate touchDelegate = new TouchDelegate(bounds, view); | |
if (View.class.isInstance(view.getParent())) { | |
((View) view.getParent()).setTouchDelegate(touchDelegate); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment