当前位置: 首页>>代码示例>>Java>>正文


Java WindowInsetsCompat.getSystemWindowInsetLeft方法代码示例

本文整理汇总了Java中android.support.v4.view.WindowInsetsCompat.getSystemWindowInsetLeft方法的典型用法代码示例。如果您正苦于以下问题:Java WindowInsetsCompat.getSystemWindowInsetLeft方法的具体用法?Java WindowInsetsCompat.getSystemWindowInsetLeft怎么用?Java WindowInsetsCompat.getSystemWindowInsetLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.WindowInsetsCompat的用法示例。


在下文中一共展示了WindowInsetsCompat.getSystemWindowInsetLeft方法的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.getSystemWindowInsetLeft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。