什么是windowBackground和背景的活动风格之间的差异?差异、背景、风格、windowBackground

2023-09-12 04:41:37 作者:≮璃落★幽客≯

我有一个背景,所有使用机器人:背景应用程序的活动设置的样式参数和设置应用程序的主题链接到这种风格。

I have a background set for all of the activities of the app by using the "android:background" parameter in the styles and setting the theme of the application to link to this style.

所有运作良好,直到我注意到,与项目列表的对话框,它使每个项目有背景的全尺寸。

All worked well, till I've noticed that for a dialog with a list of items, it makes each item to have the full size of the background .

更改参数后,被用来机器人:windowBackground它似乎在这种情况下正常工作了。

After changing the parameter being used to "android:windowBackground" it seems to work fine in this case too.

为什么会出现这种问题?两者之间的区别是什么?

Why does it occur? What is the difference between the two?

此外,没有设置机器人:windowBackground以@null为写到这里提供相同的速度提升为使用?机器人:背景

Also , does setting "android:windowBackground" to @null as written here provide the same speed boost as using "android:background"?

推荐答案

机器人:背景是背景色(绘制为precise)视图组件,其中由于Android的:windowBackground是窗口的背景颜色(活动或对话)中,你的观点所在。

android:background is the background color (drawable to be precise) of a view component where as android:windowBackground is the background color of the window (activity or dialog) in which your view resides.

默认视图的是透明的,即没有背景颜色,以便在视觉上看起来他们是从基础窗口取色。

By default view's are transparent i.e no background color so visually it looks like they are taking the color from the underlying window.

请注意您链接的文章中提到设置windowBackground为空,而不是背景,全屏views.This是一种常见的技术,避免透支。

Notice how the article you linked to mentions setting the windowBackground to null and not the background for fullscreen views.This is a common technique to avoid overdraws.

但是,同样的原理可以应用到的意见,如果你有一个观点完全隐藏的另一种观点。

But the same principle can be applied to views if you have one view completely hide the other view.

例: gist.github.com/floatingmonkey/5474959