List of usage examples for android.widget TextView getHitRect
public void getHitRect(Rect outRect)
From source file:cl.monsoon.s1next.binding.TextViewBindingAdapter.java
@BindingAdapter("increaseClickingArea") public static void increaseClickingArea(TextView textView, float size) { // fork from http://stackoverflow.com/a/1343796 View parent = (View) textView.getParent(); // post in the parent's message queue to make sure the parent // lays out its children before we call View#getHitRect() parent.post(() -> {//from ww w . ja va2s . c om final int halfSize = (int) (size / 2 + 0.5); Rect rect = new Rect(); textView.getHitRect(rect); rect.top -= halfSize; rect.right += halfSize; rect.bottom += halfSize; rect.left -= halfSize; // use TouchDelegate to increase count's clicking area parent.setTouchDelegate(new TouchDelegate(rect, textView)); }); }