本文整理匯總了Java中android.support.v4.view.WindowInsetsCompat類的典型用法代碼示例。如果您正苦於以下問題:Java WindowInsetsCompat類的具體用法?Java WindowInsetsCompat怎麽用?Java WindowInsetsCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WindowInsetsCompat類屬於android.support.v4.view包,在下文中一共展示了WindowInsetsCompat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
});
}
示例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);
}
});
}
示例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;
}
示例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);
}
}
示例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();
}
});
}
示例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;
}
};
}
示例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);
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
});
}