本文整理汇总了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);
}
}
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
}
}
}
示例9: onAttachedToWindow
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (ViewCompat.getFitsSystemWindows(this)) {
ViewCompat.requestApplyInsets(this);
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}
示例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();
}