问题描述
我想在我的应用程序使用Theme.Wallpaper。这个主题采用了手机当前的墙纸作为背景。问题是,它并没有一个4.1的设备上运行。我也试过在我的风格资源重新创建Theme.Wallpaper却又不为4.1的设备。
- 注意,这可能不是较低的API以及工作,我只是证实了它的工作2.2.1,而不是工作4.1。
我想知道为什么它不工作,如果有任何解决这一点。
I wanted to use Theme.Wallpaper in my app. This theme uses the phones current wallpaper as a background. The problem is it doesn't work on a 4.1 device. I also tried recreating the Theme.Wallpaper in my style resources but again it doesn't work for 4.1 devices.- note that it may not work for lower APIs as well, I only confirmed it working on 2.2.1 and not working on 4.1.I would like to know why it doesn't work and if there is any solution to that.
推荐答案
我终于找到了答案,这是一个有点复杂:
I have finally found the answer, it's a bit complex:
在建为一个目标14以上(我的是17)自动Eclipse将创建一个值-V11和价值-V14文件夹(applyed的电话或自动真空淀积系统与API版本14及以上或11以上的项目)。在这些文件夹是包含了AppBaseTheme的风格style.xml文件,这个AppBaseTheme的风格取代了一个在默认的值的文件夹,这是(或:被延长)父AppTheme的风格,默认情况下,applyed应用程序。
In a project built for a target above 14 (mine is 17) eclipse automatically creates a "values-v11" and a "values-v14" folders (applyed for phones or AVDs with api version 14 and above or 11 and above). In those folders are style.xml files that contain the "AppBaseTheme" style, This "AppBaseTheme" style replaces the one in the default "values" folder, which is the parent of (or: is extended by) the "AppTheme" style that is applyed by default to the application..
现在,我选择了Theme.Wallpaper样式应用到我的应用程序的方式,是让我的AppBaseTheme继承它。理解这一点,为什么我的应用程序没有一个Theme.Wallpaper像API 11及以上的系统行为很明显:我从来没有替代V11 V14和AppBaseTheme延长Theme.Wallpaper或更适合Theme.Holo.Wallpaper为V11,和Theme.DeviceDefault.Wallpaper为V14。
Now, the way I chose to apply the "Theme.Wallpaper" style to my app, was to have my "AppBaseTheme" inherit from it. Understanding this, it became obvious why my app did not have a "Theme.Wallpaper" like behavior on Systems with API 11 and above: I never made the alternative v11 and v14 "AppBaseTheme" extend the "Theme.Wallpaper" or the more suitable "Theme.Holo.Wallpaper" for v11, and "Theme.DeviceDefault.Wallpaper" for v14.
所以,如果你有麻烦与应用样式,我希望你看这...
So, if you have troubles with applying styles, I hope you see this...
编辑:如果你读这篇文章,并与编辑在Eclipse中style.xml文件的麻烦,尝试在任何文本编辑器打开此文件(我最喜欢的是记事本++),只是删除所有比重新打开它在Eclipse上的意见。如果您需要注释只需添加他们后记你的文本编辑器。
if your reading this, and have troubles with editing the style.xml file in eclipse, try opening this file in any text editor (my favorite is notepad++) and just delete all the comments than reopen it on eclipse. In case you need comments just add them afterwords on your text editor.
这篇关于使用手机壁纸作为背景的应用程序 - Theme.Wallpaper样的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!