本文整理了Java中android.view.View.setOnApplyWindowInsetsListener()
方法的一些代码示例,展示了View.setOnApplyWindowInsetsListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。View.setOnApplyWindowInsetsListener()
方法的具体详情如下:
包路径:android.view.View
类名称:View
方法名:setOnApplyWindowInsetsListener
暂无
代码示例来源:origin: kingargyle/adt-leanback-support
public static void setOnApplyWindowInsetsListener(View view,
final OnApplyWindowInsetsListener listener) {
view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
// Wrap the framework insets in our wrapper
WindowInsetsCompatApi21 insets = new WindowInsetsCompatApi21(windowInsets);
// Give the listener a chance to use the wrapped insets
insets = (WindowInsetsCompatApi21) listener.onApplyWindowInsets(view, insets);
// Return the unwrapped insets
return insets.unwrap();
}
});
}
}
代码示例来源:origin: eliotstocker/Light-Controller
/**
* Initialized to determine screen shape
* @param view
*/
private static void initShapeDetection(View view){
view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
if (insets.isRound()) {
shape = ScreenShape.ROUND;
if(screenWidthPX == 320 && screenHeightPX == 290) {
shape = ScreenShape.MOTO_ROUND;
}
} else {
shape = ScreenShape.RECTANGLE;
}
if(onShapeChangeListener != null){
onShapeChangeListener.shapeDetected(getShape());
}
return insets;
}
});
}
代码示例来源:origin: kingargyle/adt-leanback-support
public static void configureApplyInsets(View drawerLayout) {
if (drawerLayout instanceof DrawerLayoutImpl) {
drawerLayout.setOnApplyWindowInsetsListener(new InsetsListener());
drawerLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
代码示例来源:origin: mtotschnig/MyExpenses
/**
* Set a view to be resized when the keyboard is shown. This will set the bottom margin of the
* view to be immediately above the keyboard, and assumes that the view sits immediately above
* the navigation bar.
*
* <p>Note that you must set {@link android.R.attr#windowSoftInputMode} to {@code adjustResize}
* for this class to work. Otherwise window insets are not dispatched and this method will have
* no effect.
*
* <p>This will only take effect in versions Lollipop or above. Otherwise this is a no-op.
*
* @param view The view to be resized when the keyboard is shown.
*/
public static void setImeInsetView(final View view) {
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
view.setOnApplyWindowInsetsListener(new WindowInsetsListener());
}
}
代码示例来源:origin: listenzz/AndroidNavigation
public static void setStatusBarTranslucent(Window window, boolean translucent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setRenderContentInShortEdgeCutoutAreas(window, translucent);
View decorView = window.getDecorView();
if (translucent) {
decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
WindowInsets defaultInsets = v.onApplyWindowInsets(insets);
return defaultInsets.replaceSystemWindowInsets(
defaultInsets.getSystemWindowInsetLeft(),
0,
defaultInsets.getSystemWindowInsetRight(),
defaultInsets.getSystemWindowInsetBottom());
}
});
} else {
decorView.setOnApplyWindowInsetsListener(null);
}
ViewCompat.requestApplyInsets(decorView);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (translucent) {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
ViewCompat.requestApplyInsets(window.getDecorView());
}
}
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
final View container = findViewById(R.id.preference_fragment_container);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart() /*+ insets.getSystemWindowInsetLeft()*/,
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() /*+ insets.getSystemWindowInsetRight()*/,
toolbar.getPaddingBottom());
aboutText.setPadding(aboutText.getPaddingStart(),
aboutText.getPaddingTop(),
aboutText.getPaddingEnd(),
aboutText.getPaddingBottom() + insets.getSystemWindowInsetBottom());
View viewGroup = findViewById(R.id.swipeBackView);
ViewGroup.MarginLayoutParams viewGroupParams
= (ViewGroup.MarginLayoutParams) viewGroup.getLayoutParams();
viewGroupParams.leftMargin += insets.getSystemWindowInsetLeft();
viewGroupParams.rightMargin += insets.getSystemWindowInsetRight();
viewGroup.setLayoutParams(viewGroupParams);
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart() /*+ insets.getSystemWindowInsetLeft()*/,
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() /*+ insets.getSystemWindowInsetRight()*/,
toolbar.getPaddingBottom());
ViewGroup.MarginLayoutParams toolbarParams
= (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
toolbarParams.leftMargin += insets.getSystemWindowInsetLeft();
toolbarParams.rightMargin += insets.getSystemWindowInsetRight();
toolbar.setLayoutParams(toolbarParams);
container.setPadding(container.getPaddingStart() + insets.getSystemWindowInsetLeft(),
container.getPaddingTop(),
container.getPaddingEnd() + insets.getSystemWindowInsetRight(),
container.getPaddingBottom() + insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
内容来源于网络,如有侵权,请联系作者删除!