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


Java ViewCompat.getFitsSystemWindows方法代码示例

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


在下文中一共展示了ViewCompat.getFitsSystemWindows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: forceFitsSystemWindows

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * 强制rootView下面的子View的FitsSystemWindows为false
 */
public static void forceFitsSystemWindows(ViewGroup viewGroup) {

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    int count = viewGroup.getChildCount();
    for (int i = 0; i < count; i++) {
      View view = viewGroup.getChildAt(i);
      if (view instanceof ViewGroup) {
        forceFitsSystemWindows((ViewGroup) view);
      } else {
        if (ViewCompat.getFitsSystemWindows(view)) {
          ViewCompat.setFitsSystemWindows(view, false);
        }
      }
    }
  }
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:20,代码来源:SystemBarHelper.java

示例2: onWindowInsetChanged

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) {
    WindowInsetsCompat newInsets = null;

    if (ViewCompat.getFitsSystemWindows(this)) {
        // If we're set to fit system windows, keep the insets
        newInsets = insets;
    }

    // If our insets have changed, keep them and invalidate the scroll ranges...
    if (!QMUILangHelper.objectEquals(mLastInsets, newInsets)) {
        mLastInsets = newInsets;
        requestLayout();
    }

    // Consume the insets. This is done so that child views with fitSystemWindows=true do not
    // get the default padding functionality from View
    return insets.consumeSystemWindowInsets();
}
 
开发者ID:coopese,项目名称:qmui,代码行数:19,代码来源:QMUICollapsingTopBarLayout.java

示例3: applySystemWindowInsets19

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean applySystemWindowInsets19(Rect insets) {
    Rect newInsets = null;
    if (ViewCompat.getFitsSystemWindows(this)) {
        // If we're set to fit system windows, keep the insets
        newInsets = insets;
    }

    // If our insets have changed, keep them and invalidate the scroll ranges...
    if (!QMUILangHelper.objectEquals(mLastInsets, newInsets)) {
        mLastInsetRect = newInsets;
        requestLayout();
    }

    // Consume the insets. This is done so that child views with fitSystemWindows=true do not
    // get the default padding functionality from View
    return true;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:19,代码来源:QMUICollapsingTopBarLayout.java

示例4: onLayoutChild

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean onLayoutChild(CoordinatorLayout parent, StretchView child, int layoutDirection) {
    if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) {
        ViewCompat.setFitsSystemWindows(child, true);
    }
    parent.onLayoutChild(child, layoutDirection);
    //设置起始位置
    switch (child.getDirection()) {
        case StretchView.LEFT:
            ViewCompat.offsetLeftAndRight(child, -child.getWidth() + mTranslation);
            break;
        case StretchView.RIGHT:
            ViewCompat.offsetLeftAndRight(child, parent.getWidth() - child.getLeft() - parent.getPaddingRight() + mTranslation);
            break;
        case StretchView.BOTTOM:
            ViewCompat.offsetTopAndBottom(child, parent.getHeight() - child.getTop() - parent.getPaddingBottom() + mTranslation);
            break;
    }
    return true;
}
 
开发者ID:thunderpunch,项目名称:StretchView,代码行数:21,代码来源:StretchView.java

示例5: onAttachedToWindow

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onAttachedToWindow() {
  super.onAttachedToWindow();
      resetTouchBehaviors(false);
  if (mNeedsPreDrawListener) {
    if (mOnPreDrawListener == null) {
      mOnPreDrawListener = new OnPreDrawListener();
    }
    final ViewTreeObserver vto = getViewTreeObserver();
    vto.addOnPreDrawListener(mOnPreDrawListener);
  }
  if (mLastInsets == null && ViewCompat.getFitsSystemWindows(this)) {
    // We're set to fitSystemWindows but we haven't had any insets yet...
    // We should request a new dispatch of window insets
    ViewCompat.requestApplyInsets(this);
  }
  mIsAttachedToWindow = true;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:19,代码来源:CoordinatorLayout.java

示例6: setupForInsets

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void setupForInsets() {
  if (Build.VERSION.SDK_INT < 21) {
    return;
  }

  if (ViewCompat.getFitsSystemWindows(this)) {
    if (mApplyWindowInsetsListener == null) {
      mApplyWindowInsetsListener =
          new android.support.v4.view.OnApplyWindowInsetsListener() {
            @Override
                          public WindowInsetsCompat onApplyWindowInsets(View v,
                                  WindowInsetsCompat insets) {
              return setWindowInsets(insets);
            }
          };
    }
    // First apply the insets listener
    ViewCompat.setOnApplyWindowInsetsListener(this, mApplyWindowInsetsListener);

    // Now set the sys ui flags to enable us to lay out in the window insets
          setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                  | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
  } else {
    ViewCompat.setOnApplyWindowInsetsListener(this, null);
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:27,代码来源:CoordinatorLayout.java

示例7: DrawerLayout

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public DrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mChildAccessibilityDelegate = new ChildAccessibilityDelegate();
    this.mScrimColor = DEFAULT_SCRIM_COLOR;
    this.mScrimPaint = new Paint();
    this.mFirstLayout = true;
    this.mLockModeLeft = 3;
    this.mLockModeRight = 3;
    this.mLockModeStart = 3;
    this.mLockModeEnd = 3;
    this.mShadowStart = null;
    this.mShadowEnd = null;
    this.mShadowLeft = null;
    this.mShadowRight = null;
    setDescendantFocusability(262144);
    float density = getResources().getDisplayMetrics().density;
    this.mMinDrawerMargin = (int) ((64.0f * density) + 0.5f);
    float minVel = 400.0f * density;
    this.mLeftCallback = new ViewDragCallback(3);
    this.mRightCallback = new ViewDragCallback(5);
    this.mLeftDragger = ViewDragHelper.create(this, 1.0f, this.mLeftCallback);
    this.mLeftDragger.setEdgeTrackingEnabled(1);
    this.mLeftDragger.setMinVelocity(minVel);
    this.mLeftCallback.setDragger(this.mLeftDragger);
    this.mRightDragger = ViewDragHelper.create(this, 1.0f, this.mRightCallback);
    this.mRightDragger.setEdgeTrackingEnabled(2);
    this.mRightDragger.setMinVelocity(minVel);
    this.mRightCallback.setDragger(this.mRightDragger);
    setFocusableInTouchMode(true);
    ViewCompat.setImportantForAccessibility(this, 1);
    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
    if (ViewCompat.getFitsSystemWindows(this)) {
        IMPL.configureApplyInsets(this);
        this.mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context);
    }
    this.mDrawerElevation = 10.0f * density;
    this.mNonDrawerViews = new ArrayList();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:40,代码来源:DrawerLayout.java

示例8: forceFitsSystemWindows

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public static void forceFitsSystemWindows(ViewGroup viewGroup) {
    if (VERSION.SDK_INT >= 19) {
        int count = viewGroup.getChildCount();
        for (int i = 0; i < count; i++) {
            View view = viewGroup.getChildAt(i);
            if (view instanceof ViewGroup) {
                forceFitsSystemWindows((ViewGroup) view);
            } else if (ViewCompat.getFitsSystemWindows(view)) {
                ViewCompat.setFitsSystemWindows(view, false);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:SystemBarHelper.java

示例9: onAttachedToWindow

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if (ViewCompat.getFitsSystemWindows(this)) {
        ViewCompat.requestApplyInsets(this);
    }
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:8,代码来源:QMUIWindowInsetLayout.java

示例10: onLayoutChild

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) {
    // First let the parent lay it out
    if (mState != STATE_DRAGGING && mState != STATE_SETTLING) {
        if (ViewCompat.getFitsSystemWindows(parent) &&
                !ViewCompat.getFitsSystemWindows(child)) {
            ViewCompat.setFitsSystemWindows(child, true);
        }
        parent.onLayoutChild(child, layoutDirection);
    }
    // Offset the bottom sheet
    mParentHeight = parent.getHeight();
    mMinOffset = Math.max(0, mParentHeight - child.getHeight());
    mMaxOffset = Math.max(mParentHeight - mPeekHeight, mMinOffset);

    /**
     * New behavior
     */
    if (mState == STATE_ANCHOR_POINT) {
        ViewCompat.offsetTopAndBottom(child, mAnchorPoint);
    } else if (mState == STATE_EXPANDED) {
        ViewCompat.offsetTopAndBottom(child, mMinOffset);
    } else if (mHideable && mState == STATE_HIDDEN) {
        ViewCompat.offsetTopAndBottom(child, mParentHeight);
    } else if (mState == STATE_COLLAPSED) {
        ViewCompat.offsetTopAndBottom(child, mMaxOffset);
    }
    if (mViewDragHelper == null) {
        mViewDragHelper = ViewDragHelper.create(parent, mDragCallback);
    }
    mViewRef = new WeakReference<>(child);
    mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child));
    return true;
}
 
开发者ID:aliumujib,项目名称:Nibo,代码行数:35,代码来源:BottomSheetBehaviorGoogleMapsLike.java

示例11: DrawerLayout

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public DrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mChildAccessibilityDelegate = new ChildAccessibilityDelegate();
    this.mScrimColor = DEFAULT_SCRIM_COLOR;
    this.mScrimPaint = new Paint();
    this.mFirstLayout = true;
    this.mLockModeLeft = 3;
    this.mLockModeRight = 3;
    this.mLockModeStart = 3;
    this.mLockModeEnd = 3;
    this.mShadowStart = null;
    this.mShadowEnd = null;
    this.mShadowLeft = null;
    this.mShadowRight = null;
    setDescendantFocusability(262144);
    float density = getResources().getDisplayMetrics().density;
    this.mMinDrawerMargin = (int) ((64.0f * density) + 0.5f);
    float minVel = 400.0f * density;
    this.mLeftCallback = new ViewDragCallback(3);
    this.mRightCallback = new ViewDragCallback(5);
    this.mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, this.mLeftCallback);
    this.mLeftDragger.setEdgeTrackingEnabled(1);
    this.mLeftDragger.setMinVelocity(minVel);
    this.mLeftCallback.setDragger(this.mLeftDragger);
    this.mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, this.mRightCallback);
    this.mRightDragger.setEdgeTrackingEnabled(2);
    this.mRightDragger.setMinVelocity(minVel);
    this.mRightCallback.setDragger(this.mRightDragger);
    setFocusableInTouchMode(true);
    ViewCompat.setImportantForAccessibility(this, 1);
    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
    if (ViewCompat.getFitsSystemWindows(this)) {
        IMPL.configureApplyInsets(this);
        this.mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context);
    }
    this.mDrawerElevation = TitleBar.SHAREBTN_RIGHT_MARGIN * density;
    this.mNonDrawerViews = new ArrayList();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:40,代码来源:DrawerLayout.java

示例12: onLayoutChildFixed

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public boolean onLayoutChildFixed(CoordinatorLayout parent, V child, int layoutDirection) {
    if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) {
        ViewCompat.setFitsSystemWindows(child, true);
    }
    int savedTop = child.getTop();
    // First let the parent lay it out
    parent.onLayoutChild(child, layoutDirection);
    // Offset the bottom sheet
    mParentHeight = parent.getHeight();
    int peekHeight;
    if (mPeekHeightAuto) {
        if (mPeekHeightMin == 0) {
            mPeekHeightMin = parent.getResources().getDimensionPixelSize(
                    android.support.design.R.dimen.design_bottom_sheet_peek_height_min);
        }
        peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16);
    } else {
        peekHeight = mPeekHeight;
    }
    mMinOffset = Math.max(0, mParentHeight - child.getHeight());
    mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset);
    if (mState == STATE_EXPANDED) {
        ViewCompat.offsetTopAndBottom(child, mMinOffset);
    } else if (mHideable && mState == STATE_HIDDEN) {
        ViewCompat.offsetTopAndBottom(child, mParentHeight);
    } else if (mState == STATE_COLLAPSED) {
        ViewCompat.offsetTopAndBottom(child, mMaxOffset);
    } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) {
        ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop());
    }
    if (mViewDragHelper == null) {
        mViewDragHelper = ViewDragHelper.create(parent, mDragCallback);
    }
    mViewRef = new WeakReference<>(child);
    mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child));
    return true;
}
 
开发者ID:OhMyLob,项目名称:Paper-Launcher,代码行数:38,代码来源:BottomSheetBehaviorV2.java

示例13: DebugDrawerLayout

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public DebugDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
  final float density = getResources().getDisplayMetrics().density;
  mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
  final float minVel = MIN_FLING_VELOCITY * density;

  mLeftCallback = new ViewDragCallback(Gravity.LEFT);
  mRightCallback = new ViewDragCallback(Gravity.RIGHT);

  mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
  mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
  mLeftDragger.setMinVelocity(minVel);
  mLeftCallback.setDragger(mLeftDragger);

  mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
  mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
  mRightDragger.setMinVelocity(minVel);
  mRightCallback.setDragger(mRightDragger);

  // So that we can catch the back button
  setFocusableInTouchMode(true);

  ViewCompat.setImportantForAccessibility(this,
      ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

  ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
  ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
  if (ViewCompat.getFitsSystemWindows(this)) {
    IMPL.configureApplyInsets(this);
    mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context);
  }
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:34,代码来源:DebugDrawerLayout.java

示例14: getMinOffset

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
protected int getMinOffset(AppBarLayout layout) {
  int minOffset = layout.getMeasuredHeight();
  if (mScrollFlag != null) {
    if (mScrollFlag.isFlagScrollEnabled()) {
      minOffset = layout.getMeasuredHeight() - getMinHeight(layout, false);
    }
  }
  if (ViewCompat.getFitsSystemWindows(layout)) {
    if (mStatusBarSize == 0) {
      mStatusBarSize = Utils.getStatusBarSize(layout.getContext());
    }
    minOffset -= mStatusBarSize;
  }
  return -Math.max(minOffset, 0);
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:16,代码来源:SmoothAppBarLayout.java

示例15: onLayout

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if (mLastInsets != null) {
            // Shift down any views which are not set to fit system windows
            final int insetTop = mLastInsets.getSystemWindowInsetTop();
            for (int i = 0, z = getChildCount(); i < z; i++) {
                final View child = getChildAt(i);
                if (ViewCompat.getFitsSystemWindows(child)) {
                    if (child.getTop() < insetTop) {
                        // If the child isn't set to fit system windows but is drawing within
                        // the inset offset it down
                        ViewCompat.offsetTopAndBottom(child, insetTop);
                    }
                }
            }
        }

        // Update our child view offset helpers. This needs to be done after the title has been
        // setup, so that any Toolbars are in their original position
        for (int i = 0, z = getChildCount(); i < z; i++) {
            getViewOffsetHelper(getChildAt(i)).onViewLayout();
        }

        // Update the collapsed bounds by getting it's transformed bounds
        if (mCollapsingTitleEnabled) {
            // Update the collapsed bounds
            final int maxOffset = getMaxOffsetForPinChild(
                    mTopBarDirectChild != null ? mTopBarDirectChild : mTopBar);
            QMUIViewHelper.getDescendantRect(this, mTopBar, mTmpRect);
//            mTmpRect.top = mTmpRect.top - topBarInsetAdjustTop;
            Rect rect = mTopBar.getTitleContainerRect();
            int horStart = mTmpRect.top + maxOffset;
            mCollapsingTextHelper.setCollapsedBounds(
                    mTmpRect.left + rect.left,
                    horStart + rect.top,
                    mTmpRect.left + rect.right,
                    horStart + rect.bottom);

            // Update the expanded bounds
            mCollapsingTextHelper.setExpandedBounds(
                    mExpandedMarginStart,
                    mTmpRect.top + mExpandedMarginTop,
                    right - left - mExpandedMarginEnd,
                    bottom - top - mExpandedMarginBottom);
            // Now recalculate using the new bounds
            mCollapsingTextHelper.recalculate();
        }

        // Finally, set our minimum height to enable proper AppBarLayout collapsing
        if (mTopBar != null) {
            if (mCollapsingTitleEnabled && TextUtils.isEmpty(mCollapsingTextHelper.getText())) {
                // If we do not currently have a title, try and grab it from the Toolbar
                mCollapsingTextHelper.setText(mTopBar.getTitle());
            }
            if (mTopBarDirectChild == null || mTopBarDirectChild == this) {
                setMinimumHeight(getHeightWithMargins(mTopBar));
            } else {
                setMinimumHeight(getHeightWithMargins(mTopBarDirectChild));
            }
        }

        updateScrimVisibility();
    }
 
开发者ID:coopese,项目名称:qmui,代码行数:65,代码来源:QMUICollapsingTopBarLayout.java


注:本文中的android.support.v4.view.ViewCompat.getFitsSystemWindows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。