什么是 WindowInsets? [英] What are WindowInsets?

查看:16
本文介绍了什么是 WindowInsets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解 Android 操作系统,在阅读 Google I/O 2014 应用程序时,我遇到了 WindowInsets.如果有人可以解释它们是什么,那么这将是一个很大的帮助.谢谢.

解决方案

您可以了解所有关于 WindowInsets 在这里.WindowInsets 为您提供窗口上可供应用程序使用的区域.它本身并没有多大用处.当您覆盖 View.onApplyWindowInsets 或实现 View.OnApplyWindowInsetsListener 时,它的真正目的就来了.你可以在这里阅读它们:查看.onApplyWindowInsetsView.OnApplyWindowInsetsListener.><块引用>

用于以自定义方式在视图上应用窗口插图的侦听器.

应用如果想申请可以选择实现这个接口为视图处理窗口插图的方式的自定义策略.如果设置了一个 OnApplyWindowInsetsListener,它的 onApplyWindowInsets 方法将被调用而不是视图自己的 onApplyWindowInsets 方法.侦听器可以选择调用参数 View 的onApplyWindowInsets 方法将视图的正常行为应用为一部分自己的.

简而言之,覆盖它可以让您控制可用于您的视图的窗口区域.

I am trying to learn about the Android OS and while I was reading the Google I/O 2014 app, I came across the WindowInsets. If anyone can explain what they are then it would be a great help. Thank you.

解决方案

You can learn all about WindowInsets here. WindowInsets provides you with the area on the window that is usable by the application. By itself it's of not much use. It's true purpose comes when you either override View.onApplyWindowInsets or implement View.OnApplyWindowInsetsListener. You can read about them here: View.onApplyWindowInsets and View.OnApplyWindowInsetsListener.

Listener for applying window insets on a view in a custom way.

Apps may choose to implement this interface if they want to apply custom policy to the way that window insets are treated for a view. If an OnApplyWindowInsetsListener is set, its onApplyWindowInsets method will be called instead of the View's own onApplyWindowInsets method. The listener may optionally call the parameter View's onApplyWindowInsets method to apply the View's normal behavior as part of its own.

In short, overriding this will let you control area of the window available for your View.

这篇关于什么是 WindowInsets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆