-
Notifications
You must be signed in to change notification settings - Fork 375
TouchMarginView
ZieIony edited this page May 19, 2015
·
1 revision
public interface TouchMarginView {
void setTouchMargin(int left, int top, int right, int bottom);
void setTouchMarginLeft(int margin);
void setTouchMarginTop(int margin);
void setTouchMarginRight(int margin);
void setTouchMarginBottom(int margin);
Rect getTouchMargin();
}
private Rect touchMargin;
@Override
public void setTouchMargin(int left, int top, int right, int bottom) {
touchMargin = new Rect(left, top, right, bottom);
}
@Override
public void setTouchMarginLeft(int margin) {
touchMargin.left = margin;
}
@Override
public void setTouchMarginTop(int margin) {
touchMargin.top = margin;
}
@Override
public void setTouchMarginRight(int margin) {
touchMargin.right = margin;
}
@Override
public void setTouchMarginBottom(int margin) {
touchMargin.bottom = margin;
}
@Override
public Rect getTouchMargin() {
return touchMargin;
}
public void getHitRect(Rect outRect) {
if (touchMargin == null) {
super.getHitRect(outRect);
return;
}
outRect.set(getLeft() - touchMargin.left, getTop() - touchMargin.top, getRight() + touchMargin.right, getBottom() + touchMargin.bottom);
}
Copyright 2015 Marcin Korniluk 'Zielony'