當前位置: 首頁>>代碼示例>>Java>>正文


Java WindowInsetsCompat.getSystemWindowInsetRight方法代碼示例

本文整理匯總了Java中android.support.v4.view.WindowInsetsCompat.getSystemWindowInsetRight方法的典型用法代碼示例。如果您正苦於以下問題:Java WindowInsetsCompat.getSystemWindowInsetRight方法的具體用法?Java WindowInsetsCompat.getSystemWindowInsetRight怎麽用?Java WindowInsetsCompat.getSystemWindowInsetRight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.view.WindowInsetsCompat的用法示例。


在下文中一共展示了WindowInsetsCompat.getSystemWindowInsetRight方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
        }

    };
}
 
開發者ID:michael-rapp,項目名稱:AndroidMaterialDialog,代碼行數:25,代碼來源:MaterialDialogDecorator.java

示例2: 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;
}
 
開發者ID:oxoooo,項目名稱:earth,代碼行數:27,代碼來源:WindowInsetsFrameLayout.java

示例3: 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;
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:36,代碼來源:QMUIWindowInsetHelper.java

示例4: layoutChild

import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
@Override
  protected void layoutChild(final CoordinatorLayout parent, final View child,
          final int layoutDirection) {
  final List<View> dependencies = parent.getDependencies(child);
  final View header = findFirstDependency(dependencies);

  if (header != null) {
    final CoordinatorLayout.LayoutParams lp =
        (CoordinatorLayout.LayoutParams) child.getLayoutParams();
    final Rect available = mTempRect1;
          available.set(parent.getPaddingLeft() + lp.leftMargin,
        header.getBottom() + lp.topMargin,
        parent.getWidth() - parent.getPaddingRight() - lp.rightMargin,
                  parent.getHeight() + header.getBottom()
                          - parent.getPaddingBottom() - lp.bottomMargin);

    final WindowInsetsCompat parentInsets = parent.getLastWindowInsets();
          if (parentInsets != null && ViewCompat.getFitsSystemWindows(parent)
        && !ViewCompat.getFitsSystemWindows(child)) {
      // If we're set to handle insets but this child isn't, then it has been measured as
      // if there are no insets. We need to lay it out to match horizontally.
      // Top and bottom and already handled in the logic above
      available.left += parentInsets.getSystemWindowInsetLeft();
      available.right -= parentInsets.getSystemWindowInsetRight();
    }

    final Rect out = mTempRect2;
          GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(),
                  child.getMeasuredHeight(), available, out, layoutDirection);

    final int overlap = getOverlapPixelsForOffset(header);

    child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
    mVerticalLayoutGap = out.top - header.getBottom();
  } else {
    // If we don't have a dependency, let super handle it
    super.layoutChild(parent, child, layoutDirection);
    mVerticalLayoutGap = 0;
  }
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:41,代碼來源:HeaderScrollingViewBehavior.java

示例5: 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;
        }

    };
}
 
開發者ID:michael-rapp,項目名稱:ChromeLikeTabSwitcher,代碼行數:38,代碼來源:MainActivity.java

示例6: 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);
}
 
開發者ID:oxoooo,項目名稱:mr-mantou-android,代碼行數:9,代碼來源:WindowInsetsCompatUtil.java

示例7: layoutChild

import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
@Override
protected void layoutChild(final CoordinatorLayout parent, final View child,
                           final int layoutDirection) {
    final List<View> dependencies = parent.getDependencies(child);
    final View header = findFirstDependency(dependencies);

    if (header != null) {
        final CoordinatorLayout.LayoutParams lp =
                (CoordinatorLayout.LayoutParams) child.getLayoutParams();
        final Rect available = mTempRect1;
        available.set(parent.getPaddingLeft() + lp.leftMargin,
                header.getBottom() + lp.topMargin,
                parent.getWidth() - parent.getPaddingRight() - lp.rightMargin,
                parent.getHeight() + header.getBottom()
                        - parent.getPaddingBottom() - lp.bottomMargin);

        //修改代碼,通過反射執行getLastWindowInsets()方法
        try {
            Method method = parent.getClass().getDeclaredMethod("getLastWindowInsets", (Class<?>[]) new Object[]{});
            method.setAccessible(true);
            final WindowInsetsCompat parentInsets = (WindowInsetsCompat) method.invoke(parent);
            if (parentInsets != null && ViewCompat.getFitsSystemWindows(parent)
                    && !ViewCompat.getFitsSystemWindows(child)) {
                // If we're set to handle insets but this child isn't, then it has been measured as
                // if there are no insets. We need to lay it out to match horizontally.
                // Top and bottom and already handled in the logic above
                available.left += parentInsets.getSystemWindowInsetLeft();
                available.right -= parentInsets.getSystemWindowInsetRight();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        final Rect out = mTempRect2;
        GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(),
                child.getMeasuredHeight(), available, out, layoutDirection);

        final int overlap = getOverlapPixelsForOffset(header);

        child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
        mVerticalLayoutGap = out.top - header.getBottom();
    } else {
        // If we don't have a dependency, let super handle it
        super.layoutChild(parent, child, layoutDirection);
        mVerticalLayoutGap = 0;
    }
}
 
開發者ID:Othershe,項目名稱:BehaviorDemo,代碼行數:48,代碼來源:HeaderScrollingViewBehavior.java

示例8: layoutChild

import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
@Override
protected void layoutChild(
    final CoordinatorLayout parent, final View child, final int layoutDirection) {
  final List<View> dependencies = parent.getDependencies(child);
  final View header = findFirstDependency(dependencies);

  if (header != null) {
    final CoordinatorLayout.LayoutParams lp =
        (CoordinatorLayout.LayoutParams) child.getLayoutParams();
    final Rect available = tempRect1;
    available.set(
        parent.getPaddingLeft() + lp.leftMargin,
        header.getBottom() + lp.topMargin,
        parent.getWidth() - parent.getPaddingRight() - lp.rightMargin,
        parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin);

    final WindowInsetsCompat parentInsets = parent.getLastWindowInsets();
    if (parentInsets != null
        && ViewCompat.getFitsSystemWindows(parent)
        && !ViewCompat.getFitsSystemWindows(child)) {
      // If we're set to handle insets but this child isn't, then it has been measured as
      // if there are no insets. We need to lay it out to match horizontally.
      // Top and bottom and already handled in the logic above
      available.left += parentInsets.getSystemWindowInsetLeft();
      available.right -= parentInsets.getSystemWindowInsetRight();
    }

    final Rect out = tempRect2;
    GravityCompat.apply(
        resolveGravity(lp.gravity),
        child.getMeasuredWidth(),
        child.getMeasuredHeight(),
        available,
        out,
        layoutDirection);

    final int overlap = getOverlapPixelsForOffset(header);

    child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
    verticalLayoutGap = out.top - header.getBottom();
  } else {
    // If we don't have a dependency, let super handle it
    super.layoutChild(parent, child, layoutDirection);
    verticalLayoutGap = 0;
  }
}
 
開發者ID:material-components,項目名稱:material-components-android,代碼行數:47,代碼來源:HeaderScrollingViewBehavior.java

示例9: layoutChild

import android.support.v4.view.WindowInsetsCompat; //導入方法依賴的package包/類
@Override
protected void layoutChild(
    final CoordinatorLayout parent, final View child, final int layoutDirection) {
  final List<View> dependencies = parent.getDependencies(child);
  final View header = findFirstDependency(dependencies);

  if (header != null) {
    final CoordinatorLayout.LayoutParams lp =
        (CoordinatorLayout.LayoutParams) child.getLayoutParams();
    final Rect available = mTempRect1;
    available.set(
        parent.getPaddingLeft() + lp.leftMargin,
        header.getBottom() + lp.topMargin,
        parent.getWidth() - parent.getPaddingRight() - lp.rightMargin,
        parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin);

    final WindowInsetsCompat parentInsets = parent.getLastWindowInsets();
    if (parentInsets != null
        && ViewCompat.getFitsSystemWindows(parent)
        && !ViewCompat.getFitsSystemWindows(child)) {
      // If we're set to handle insets but this child isn't, then it has been measured as
      // if there are no insets. We need to lay it out to match horizontally.
      // Top and bottom and already handled in the logic above
      available.left += parentInsets.getSystemWindowInsetLeft();
      available.right -= parentInsets.getSystemWindowInsetRight();
    }

    final Rect out = mTempRect2;
    GravityCompat.apply(
        resolveGravity(lp.gravity),
        child.getMeasuredWidth(),
        child.getMeasuredHeight(),
        available,
        out,
        layoutDirection);

    final int overlap = getOverlapPixelsForOffset(header);

    child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
    mVerticalLayoutGap = out.top - header.getBottom();
  } else {
    // If we don't have a dependency, let super handle it
    super.layoutChild(parent, child, layoutDirection);
    mVerticalLayoutGap = 0;
  }
}
 
開發者ID:google,項目名稱:iosched,代碼行數:47,代碼來源:HeaderScrollingViewBehavior.java


注:本文中的android.support.v4.view.WindowInsetsCompat.getSystemWindowInsetRight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。