本文整理汇总了Java中android.support.v4.view.WindowInsetsCompat类的典型用法代码示例。如果您正苦于以下问题:Java WindowInsetsCompat类的具体用法?Java WindowInsetsCompat怎么用?Java WindowInsetsCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WindowInsetsCompat类属于android.support.v4.view包,在下文中一共展示了WindowInsetsCompat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ScrimInsetsFrameLayout
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mTempRect = new Rect();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout);
this.mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
a.recycle();
setWillNotDraw(true);
ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() {
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
if (ScrimInsetsFrameLayout.this.mInsets == null) {
ScrimInsetsFrameLayout.this.mInsets = new Rect();
}
ScrimInsetsFrameLayout.this.mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
ScrimInsetsFrameLayout.this.onInsetsChanged(ScrimInsetsFrameLayout.this.mInsets);
ScrimInsetsFrameLayout scrimInsetsFrameLayout = ScrimInsetsFrameLayout.this;
boolean z = ScrimInsetsFrameLayout.this.mInsets.isEmpty() || ScrimInsetsFrameLayout.this.mInsetForeground == null;
scrimInsetsFrameLayout.setWillNotDraw(z);
ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
return insets.consumeSystemWindowInsets();
}
});
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:ScrimInsetsFrameLayout.java
示例2: AppBarLayout
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
public AppBarLayout(Context context, AttributeSet attrs) {
super(context, attrs);
this.mTotalScrollRange = -1;
this.mDownPreScrollRange = -1;
this.mDownScrollRange = -1;
this.mPendingAction = 0;
setOrientation(1);
ThemeUtils.checkAppCompatTheme(context);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBarLayout, 0, R.style.Widget_Design_AppBarLayout);
this.mTargetElevation = (float) a.getDimensionPixelSize(R.styleable.AppBarLayout_elevation, 0);
setBackgroundDrawable(a.getDrawable(R.styleable.AppBarLayout_android_background));
if (a.hasValue(R.styleable.AppBarLayout_expanded)) {
setExpanded(a.getBoolean(R.styleable.AppBarLayout_expanded, false));
}
a.recycle();
ViewUtils.setBoundsViewOutlineProvider(this);
this.mListeners = new ArrayList();
ViewCompat.setElevation(this, this.mTargetElevation);
ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() {
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
return AppBarLayout.this.onWindowInsetChanged(insets);
}
});
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:AppBarLayout.java
示例3: 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;
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:CoordinatorLayout.java
示例4: setupForInsets
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
private void setupForInsets() {
if (Build.VERSION.SDK_INT < 21) {
return;
}
if (ViewCompat.getFitsSystemWindows(this)) {
if (applyWindowInsetsListener == null) {
applyWindowInsetsListener =
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, applyWindowInsetsListener);
// 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:material-components,项目名称:material-components-android,代码行数:26,代码来源:CoordinatorLayout.java
示例5: ScrimInsetsFrameLayout
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
R.style.Widget_Design_ScrimInsetsFrameLayout);
mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
a.recycle();
setWillNotDraw(true); // No need to draw until the insets are adjusted
ViewCompat.setOnApplyWindowInsetsListener(this,
new android.support.v4.view.OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(View v,
WindowInsetsCompat insets) {
if (null == mInsets) {
mInsets = new Rect();
}
mInsets.set(insets.getSystemWindowInsetLeft(),
insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(),
insets.getSystemWindowInsetBottom());
setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
return insets.consumeSystemWindowInsets();
}
});
}
开发者ID:sysdharma,项目名称:py-eventos-android,代码行数:27,代码来源:ScrimInsetsFrameLayout.java
示例6: 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
示例7: setStatusBarColor
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
/**
* set StatusBarColor
*/
public static void setStatusBarColor(Activity activity, int statusColor) {
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(statusColor);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
View mChildView = mContentView.getChildAt(0);
if (mChildView != null) {
ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
return insets;
}
});
ViewCompat.setFitsSystemWindows(mChildView, true);
ViewCompat.requestApplyInsets(mChildView);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:StatusBarCompatLollipop.java
示例8: setWindowInsets
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
private WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) {
if (Build.VERSION.SDK_INT >= 21 && mWindowInsetLayoutWR.get() != null) {
if (mWindowInsetLayoutWR.get().applySystemWindowInsets21(insets)) {
return insets.consumeSystemWindowInsets();
}
}
return insets;
}
开发者ID:coopese,项目名称:qmui,代码行数:9,代码来源:QMUIWindowInsetHelper.java
示例9: onWindowInsetChanged
import android.support.v4.view.WindowInsetsCompat; //导入依赖的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
示例10: onWindowInsetChanged
import android.support.v4.view.WindowInsetsCompat; //导入依赖的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 (!ObjectsCompat.equals(mLastInsets, newInsets)) {
mLastInsets = newInsets;
invalidateScrollRanges();
}
return insets;
}
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:17,代码来源:AppBarLayout.java
示例11: dispatchApplyWindowInsetsToBehaviors
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
private WindowInsetsCompat dispatchApplyWindowInsetsToBehaviors(WindowInsetsCompat insets) {
if (insets.isConsumed()) {
return insets;
}
for (int i = 0, z = getChildCount(); i < z; i++) {
final View child = getChildAt(i);
if (ViewCompat.getFitsSystemWindows(child)) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final Behavior b = lp.getBehavior();
if (b != null) {
// If the view has a behavior, let it try first
insets = b.onApplyWindowInsets(this, child, insets);
if (insets.isConsumed()) {
// If it consumed the insets, break
break;
}
}
}
}
return insets;
}
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:25,代码来源:CoordinatorLayout.java
示例12: setupForInsets
import android.support.v4.view.WindowInsetsCompat; //导入依赖的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
示例13: dispatchApplyWindowInsetsToBehaviors
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
private WindowInsetsCompat dispatchApplyWindowInsetsToBehaviors(WindowInsetsCompat insets) {
if (insets.isConsumed()) {
return insets;
}
int z = getChildCount();
for (int i = 0; i < z; i++) {
View child = getChildAt(i);
if (ViewCompat.getFitsSystemWindows(child)) {
Behavior b = ((LayoutParams) child.getLayoutParams()).getBehavior();
if (b != null) {
insets = b.onApplyWindowInsets(this, child, insets);
if (insets.isConsumed()) {
break;
}
} else {
continue;
}
}
}
return insets;
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:CoordinatorLayout.java
示例14: applySystemWindowInsets21
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
@Override
public boolean applySystemWindowInsets21(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();
}
return true;
}
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:17,代码来源:QMUICollapsingTopBarLayout.java
示例15: ScrimInsetsFrameLayout
import android.support.v4.view.WindowInsetsCompat; //导入依赖的package包/类
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mTempRect = new Rect();
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.SnvScrimInsetsFrameLayout,
defStyleAttr,
R.style.SnvScrimInsetsFrameLayout);
this.mInsetForeground = a.getDrawable(R.styleable.SnvScrimInsetsFrameLayout_snvInsetForeground);
a.recycle();
this.setWillNotDraw(true);
ViewCompat.setOnApplyWindowInsetsListener(this,
new android.support.v4.view.OnApplyWindowInsetsListener() {
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
if (null == ScrimInsetsFrameLayout.this.mInsets) {
ScrimInsetsFrameLayout.this.mInsets = new Rect();
}
ScrimInsetsFrameLayout.this.mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
ScrimInsetsFrameLayout.this.setWillNotDraw(ScrimInsetsFrameLayout.this.mInsets.isEmpty() || ScrimInsetsFrameLayout.this.mInsetForeground == null);
ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
return insets.consumeSystemWindowInsets();
}
});
}
开发者ID:vikramkakkar,项目名称:SublimeNavigationView,代码行数:25,代码来源:ScrimInsetsFrameLayout.java
示例16: onWindowInsetChanged
import android.support.v4.view.WindowInsetsCompat; //导入依赖的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 (!ObjectsCompat.equals(lastInsets, newInsets)) {
lastInsets = newInsets;
invalidateScrollRanges();
}
return insets;
}
开发者ID:material-components,项目名称:material-components-android,代码行数:17,代码来源:AppBarLayout.java
示例17: onWindowInsetChanged
import android.support.v4.view.WindowInsetsCompat; //导入依赖的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 (!ObjectsCompat.equals(lastInsets, newInsets)) {
lastInsets = 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:material-components,项目名称:material-components-android,代码行数:19,代码来源:CollapsingToolbarLayout.java
示例18: 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();
}
}
开发者ID:mobvoi,项目名称:ticdesign,代码行数:27,代码来源:CoordinatorLayout.java
示例19: onWindowInsetChanged
import android.support.v4.view.WindowInsetsCompat; //导入依赖的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 (!ObjectsCompat.equals(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:opacapp,项目名称:multiline-collapsingtoolbar,代码行数:19,代码来源:CollapsingToolbarLayout.java
示例20: 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
注:本文中的android.support.v4.view.WindowInsetsCompat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论