-
Notifications
You must be signed in to change notification settings - Fork 377
InsetView
ZieIony edited this page May 19, 2015
·
2 revisions
public interface InsetView {
public static int INSET_NULL = -1;
void setInset(int left, int top, int right, int bottom);
void setInsetColor(int color);
}
int insetLeft = INSET_NULL, insetTop = INSET_NULL, insetRight = INSET_NULL, insetBottom = INSET_NULL;
int insetColor;
private OnInsetsChangedListener onInsetsChangedListener;
public int getInsetColor() {
return insetColor;
}
public void setInsetColor(int insetsColor) {
this.insetColor = insetsColor;
}
public void setInset(int left, int top, int right, int bottom) {
insetLeft = left;
insetTop = top;
insetRight = right;
insetBottom = bottom;
}
public int getInsetLeft() {
return insetLeft;
}
public void setInsetLeft(int insetLeft) {
this.insetLeft = insetLeft;
}
public int getInsetTop() {
return insetTop;
}
public void setInsetTop(int insetTop) {
this.insetTop = insetTop;
}
public int getInsetRight() {
return insetRight;
}
public void setInsetRight(int insetRight) {
this.insetRight = insetRight;
}
public int getInsetBottom() {
return insetBottom;
}
public void setInsetBottom(int insetBottom) {
this.insetBottom = insetBottom;
}
@Override
protected boolean fitSystemWindows(Rect insets) {
if (insetLeft == INSET_NULL)
insetLeft = insets.left;
if (insetTop == INSET_NULL)
insetTop = insets.top;
if (insetRight == INSET_NULL)
insetRight = insets.right;
if (insetBottom == INSET_NULL)
insetBottom = insets.bottom;
insets.set(insetLeft, insetTop, insetRight, insetBottom);
if (onInsetsChangedListener != null)
onInsetsChangedListener.onInsetsChanged();
postInvalidate();
return super.fitSystemWindows(insets);
}
public void setOnInsetsChangedListener(OnInsetsChangedListener onInsetsChangedListener) {
this.onInsetsChangedListener = onInsetsChangedListener;
}
Copyright 2015 Marcin Korniluk 'Zielony'