本文整理匯總了Java中android.support.v4.view.WindowInsetsCompat.getSystemWindowInsetTop方法的典型用法代碼示例。如果您正苦於以下問題:Java WindowInsetsCompat.getSystemWindowInsetTop方法的具體用法?Java WindowInsetsCompat.getSystemWindowInsetTop怎麽用?Java WindowInsetsCompat.getSystemWindowInsetTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.view.WindowInsetsCompat
的用法示例。
在下文中一共展示了WindowInsetsCompat.getSystemWindowInsetTop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
private WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) {
boolean z = true;
if (this.mLastInsets == insets) {
return insets;
}
this.mLastInsets = insets;
boolean z2 = insets != null && insets.getSystemWindowInsetTop() > 0;
this.mDrawStatusBarBackground = z2;
if (this.mDrawStatusBarBackground || getBackground() != null) {
z = false;
}
setWillNotDraw(z);
insets = dispatchApplyWindowInsetsToBehaviors(insets);
requestLayout();
return insets;
}
示例2: createWindowInsetsListener
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
/**
* Creates and returns a listener, which allows to observe when window insets are applied to the
* root view of the view hierarchy, which is modified by the decorator.
*
* @return The listener, which has been created, as an instance of the type {@link
* OnApplyWindowInsetsListener}
*/
private OnApplyWindowInsetsListener createWindowInsetsListener() {
return new OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(final View v,
final WindowInsetsCompat insets) {
systemWindowInsets = insets.hasSystemWindowInsets() ?
new Rect(insets.getSystemWindowInsetLeft(),
insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(),
insets.getSystemWindowInsetBottom()) : null;
adaptLayoutParams();
return insets;
}
};
}
示例3: setWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
private void setWindowInsets(WindowInsetsCompat insets) {
if (mLastInsets != insets) {
mLastInsets = insets;
mDrawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0;
if (insets != null) {
if (insets.isRound()) {
if (!(mEdgeGlowTop instanceof CrescentEdgeEffect)) {
mEdgeGlowTop = new CrescentEdgeEffect(getContext());
mEdgeGlowBottom = new CrescentEdgeEffect(getContext());
}
} else {
if (!(mEdgeGlowTop instanceof ClassicEdgeEffect)) {
mEdgeGlowTop = new ClassicEdgeEffect(getContext());
mEdgeGlowBottom = new ClassicEdgeEffect(getContext());
}
}
mScrollBarHelper.setIsRound(insets.isRound());
}
setWillNotDraw(!mDrawStatusBarBackground && getBackground() == null && mEdgeGlowTop == null);
dispatchChildApplyWindowInsets(insets);
requestLayout();
}
}
示例4: applySystemWindowInsets21
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
@TargetApi(21)
private boolean applySystemWindowInsets21(WindowInsetsCompat insets) {
boolean consumed = false;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (!child.getFitsSystemWindows()) {
continue;
}
Rect childInsets = new Rect(
insets.getSystemWindowInsetLeft(),
insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(),
insets.getSystemWindowInsetBottom());
computeInsetsWithGravity(child, childInsets);
ViewCompat.dispatchApplyWindowInsets(child, insets.replaceSystemWindowInsets(childInsets));
consumed = true;
}
return consumed;
}
示例5: defaultApplySystemWindowInsets21
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
@TargetApi(21)
public boolean defaultApplySystemWindowInsets21(ViewGroup viewGroup, WindowInsetsCompat insets) {
if (!insets.hasSystemWindowInsets()) {
return false;
}
boolean consumed = false;
boolean showKeyboard = false;
if (insets.getSystemWindowInsetBottom() >= KEYBOARD_HEIGHT_BOUNDARY) {
showKeyboard = true;
QMUIViewHelper.setPaddingBottom(viewGroup, insets.getSystemWindowInsetBottom());
} else {
QMUIViewHelper.setPaddingBottom(viewGroup, 0);
}
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
if (jumpDispatch(child)) {
continue;
}
Rect childInsets = new Rect(
insets.getSystemWindowInsetLeft(),
insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(),
showKeyboard ? 0 : insets.getSystemWindowInsetBottom());
computeInsetsWithGravity(child, childInsets);
ViewCompat.dispatchApplyWindowInsets(child, insets.replaceSystemWindowInsets(childInsets));
consumed = true;
}
return consumed;
}
示例6: setWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
final WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) {
if (!ObjectsCompat.equals(mLastInsets, insets)) {
mLastInsets = insets;
mDrawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0;
setWillNotDraw(!mDrawStatusBarBackground && getBackground() == null);
// Now dispatch to the Behaviors
insets = dispatchApplyWindowInsetsToBehaviors(insets);
requestLayout();
}
return insets;
}
示例7: createWindowInsetsListener
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
/**
* Creates a listener, which allows to apply the window insets to the tab switcher's padding.
*
* @return The listener, which has been created, as an instance of the type {@link
* OnApplyWindowInsetsListener}. The listener may not be nullFG
*/
@NonNull
private OnApplyWindowInsetsListener createWindowInsetsListener() {
return new OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(final View v,
final WindowInsetsCompat insets) {
int left = insets.getSystemWindowInsetLeft();
int top = insets.getSystemWindowInsetTop();
int right = insets.getSystemWindowInsetRight();
int bottom = insets.getSystemWindowInsetBottom();
tabSwitcher.setPadding(left, top, right, bottom);
float touchableAreaTop = top;
if (tabSwitcher.getLayout() == Layout.TABLET) {
touchableAreaTop += getResources()
.getDimensionPixelSize(R.dimen.tablet_tab_container_height);
}
RectF touchableArea = new RectF(left, touchableAreaTop,
getDisplayWidth(MainActivity.this) - right, touchableAreaTop +
ThemeUtil.getDimensionPixelSize(MainActivity.this, R.attr.actionBarSize));
tabSwitcher.addDragGesture(
new SwipeGesture.Builder().setTouchableArea(touchableArea).create());
tabSwitcher.addDragGesture(
new PullDownGesture.Builder().setTouchableArea(touchableArea).create());
return insets;
}
};
}
示例8: dispatchApplyWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
public void dispatchApplyWindowInsets(WindowInsetsCompat insets) {
int top = insets.getSystemWindowInsetTop();
if (mPaddingTopDefault != top) {
mPaddingTopDefault = top;
if (mHeaderLayout.getChildCount() == 0) {
mMenuView.setPadding(0, mPaddingTopDefault, 0, mMenuView.getPaddingBottom());
}
}
ViewCompat.dispatchApplyWindowInsets(mHeaderLayout, insets);
}
示例9: dispatchApplyWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
public void dispatchApplyWindowInsets(WindowInsetsCompat insets) {
int top = insets.getSystemWindowInsetTop();
if (paddingTopDefault != top) {
paddingTopDefault = top;
if (headerLayout.getChildCount() == 0) {
menuView.setPadding(0, paddingTopDefault, 0, menuView.getPaddingBottom());
}
}
ViewCompat.dispatchApplyWindowInsets(headerLayout, insets);
}
開發者ID:material-components,項目名稱:material-components-android,代碼行數:11,代碼來源:NavigationMenuPresenter.java
示例10: setWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
final WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) {
if (!ObjectsCompat.equals(lastInsets, insets)) {
lastInsets = insets;
drawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0;
setWillNotDraw(!drawStatusBarBackground && getBackground() == null);
// Now dispatch to the Behaviors
insets = dispatchApplyWindowInsetsToBehaviors(insets);
requestLayout();
}
return insets;
}
示例11: copyExcluded
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
@SuppressLint("RtlHardcoded")
public static WindowInsetsCompat copyExcluded(WindowInsetsCompat source, int gravity) {
int l = (gravity & Gravity.LEFT) == Gravity.LEFT ? 0 : source.getSystemWindowInsetLeft();
int t = (gravity & Gravity.TOP) == Gravity.TOP ? 0 : source.getSystemWindowInsetTop();
int r = (gravity & Gravity.RIGHT) == Gravity.RIGHT ? 0 : source.getSystemWindowInsetRight();
int b = (gravity & Gravity.BOTTOM) == Gravity.BOTTOM ? 0 : source.getSystemWindowInsetBottom();
return source.replaceSystemWindowInsets(l, t, r, b);
}
示例12: setWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
private void setWindowInsets(WindowInsetsCompat insets) {
if (this.mLastInsets != insets) {
this.mLastInsets = insets;
this.mDrawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0;
this.setWillNotDraw(!this.mDrawStatusBarBackground && this.getBackground() == null);
this.requestLayout();
}
}
示例13: dispatchApplyWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
public void dispatchApplyWindowInsets(WindowInsetsCompat insets) {
int top = insets.getSystemWindowInsetTop();
if (mPaddingTopDefault != top) {
mPaddingTopDefault = top;
if (mHeaderLayout.getChildCount() == 0) {
mMenuView.setPadding(0, mPaddingTopDefault, 0, mMenuView.getPaddingBottom());
}
}
ViewCompat.dispatchApplyWindowInsets(mHeaderLayout, insets);
}
示例14: setWindowInsets
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
final WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) {
if (!objectEquals(mLastInsets, insets)) {
mLastInsets = insets;
mDrawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0;
setWillNotDraw(!mDrawStatusBarBackground && getBackground() == null);
// Now dispatch to the Behaviors
insets = dispatchApplyWindowInsetsToBehaviors(insets);
requestLayout();
}
return insets;
}
示例15: invalidateMenu
import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
private void invalidateMenu() {
// Mimic CollapsingToolbarLayout's CollapsingTextHelper
final WindowInsetsCompat mLastInsets = getLastInsets();
final int insetTop = mLastInsets != null ? mLastInsets.getSystemWindowInsetTop() : 0;
final int expandRange = mCollapsingToolbar.getHeight() - ViewCompat.getMinimumHeight(
mCollapsingToolbar) - insetTop;
final float expansionFraction = Math.abs(mLastVerticalOffset) / (float) expandRange;
int tintColor;
if (getExpandedTextColor() == getCollapsedTextColor())
tintColor = getExpandedTextColor();
else
tintColor = ATEUtil.blendColors(getExpandedTextColor(), getCollapsedTextColor(), expansionFraction);
if (tintColor == Color.TRANSPARENT)
tintColor = getExpandedTextColor();
mToolbar.setTitleTextColor(tintColor);
// Tint navigation icon, if any
if (mOriginalNavIcon == null)
mOriginalNavIcon = mToolbar.getNavigationIcon();
if (mOriginalNavIcon != null)
mToolbar.setNavigationIcon(TintHelper.createTintedDrawable(mOriginalNavIcon, tintColor));
// Tint action buttons
tintMenu(mToolbar, mMenu, tintColor);
// Tint overflow
if (mOriginalOverflowIcon == null) {
final ArrayList<View> overflows = new ArrayList<>();
@SuppressLint("PrivateResource")
final String overflowDescription = mContext.getString(R.string.abc_action_menu_overflow_description);
mCollapsingToolbar.findViewsWithText(overflows, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
if (!overflows.isEmpty()) {
mOverflowView = (AppCompatImageView) overflows.get(0);
mOriginalOverflowIcon = mOverflowView.getDrawable();
}
}
if (mOverflowView != null)
mOverflowView.setImageDrawable(TintHelper.createTintedDrawable(mOriginalOverflowIcon, tintColor));
}