29

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 .

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?

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

4

1 回答 1

29

android:background是视图组件的背景颜色(准确地说是可绘制的android:windowBackground),而是视图所在的窗口(活动或对话框)的背景颜色。

默认情况下,视图是透明的(即没有背景颜色),因此在视觉上看起来它们正在从底层窗口中获取颜色。

请注意您链接到的文章如何提到将 设置windowBackground为 null 而不是全屏视图的背景。这是避免过度绘制的常用技术。

但是如果您有一个视图完全隐藏另一个视图,则可以将相同的原则应用于视图。

示例:gist.github.com/floatingmonkey/5474959

于 2013-04-26T15:13:39.377 回答