Android requestWindowFeature() 的目的是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12680055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 11:25:30  来源:igfitidea点击:

What is the purpose of requestWindowFeature()?

androiduser-interface

提问by DuyguK

What does requestWindowFeature()do? I used it to create a custom titlebar, but I don't really understand what its purpose is.

有什么作用requestWindowFeature()?我用它来创建自定义标题栏,但我真的不明白它的目的是什么。

The explanation provided in the SDK documentation heredoes not make sense.

此处SDK 文档中提供的解释没有意义。

回答by Victor Ronin

Each activity has an associated window (on which the whole UI draws). This window has default way of being drawn (whether toolbar, actionbar, icons are drawn or not).

每个活动都有一个关联的窗口(整个 UI 在其上绘制)。该窗口具有默认的绘制方式(无论是否绘制工具栏、操作栏、图标)。

However, you can use requestWindowFeatureto ask the system to include or exclude some of windows features (toolbar, actionbar and so on).

但是,您可以使用requestWindowFeature要求系统包含或排除某些 Windows 功能(工具栏、操作栏等)。

Here you can find the full list of supported features: http://developer.android.com/reference/android/view/Window.html

在这里您可以找到支持功能的完整列表:http: //developer.android.com/reference/android/view/Window.html

As example, you can use FEATURE_NO_TITLEto make a window full screen or FEATURE_RIGHT_ICONto let system know that icon should be drawn on the right side.

例如,您可以使用FEATURE_NO_TITLE全屏显示窗口或FEATURE_RIGHT_ICON让系统知道应该在右侧绘制图标。