use of org.chromium.chrome.browser.compositor.CompositorViewHolderBehavior in project AndroidChromium by JackyAndroid.
the class SnackbarView method addToParent.
private void addToParent() {
// we create new LayoutParams every time.
if (mParent instanceof CoordinatorLayout) {
CoordinatorLayout.LayoutParams lp = new LayoutParams(getLayoutParams());
lp.gravity = Gravity.BOTTOM | Gravity.START;
lp.setBehavior(new CompositorViewHolderBehavior());
mParent.addView(mView, lp);
} else if (mParent instanceof FrameLayout) {
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(getLayoutParams());
lp.gravity = Gravity.BOTTOM | Gravity.START;
mParent.addView(mView, lp);
} else {
assert false : "Only FrameLayout and CoordinatorLayout are supported to show snackbars";
}
// Why setting listener on parent? It turns out that if we force a relayout in the layout
// change listener of the view itself, the force layout flag will be reset to 0 when
// layout() returns. Therefore we have to do request layout on one level above the requested
// view.
mParent.addOnLayoutChangeListener(mLayoutListener);
}
Aggregations