如何始终将背景屏幕设置为墙纸? [英] How to set the background screen as Wallpaper all the time?
问题描述
当前,我正在使用它来显示我的应用程序背景作为手机墙纸.
Currently, I'm using this to show my application background as phone wallpaper.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
但是由于某些原因,当我通过按下图标启动我的应用程序时.它仅显示带有主屏幕上图标的活动屏幕.我没有使用对话框,但它看起来像一个对话框,因为布局就是这样设置的.因此,我只想在此活动运行时显示墙纸.但是它仅在下一个事件发生(例如切换到其他活动)后才显示墙纸.我已经将代码放在onCreate()
上,并且每当我执行setContentView()
.....有办法做这种事情还是没有办法?
But for some reason when I start my application by pressing the icon. It just shows the activity screen with the icons on the home screen. I didn't use dialog but it looks like a dialog because layout is just set that way. So I just want to show the wallpaper whenever this activity is running. But it only shows the wallpaper only after the next event occurs such as switching to different activity. I already put that code on onCreate()
and whenever I do setContentView()
..... Is there way to do such thing or there is just no way?
推荐答案
经过长时间搜索和反复试验.我找到了想要的解决方案.它只是创建单独的themes.xml文件,并调整已经在默认android themes.xml中定义的Theme.Dialog.我所做的就是更改动画"部分.最初在android themes.xml中,该行是这样的.
After long search and trial and error. I've found the solution to what I wanted. It was just creating separate themes.xml file and just tweak the Theme.Dialog which is already defined in default android themes.xml. All I did was change the Animation part. Originally in android themes.xml the line looks like this.
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
,但是由于在android themes.xml中进行了修改,因此未生效.如上所述,我刚刚创建了自己的themes.xml,并将parent设置为android:Theme.Dialog.并添加了这样的一行.
but since modifying in android themes.xml doesn't take the effect. I just created my own themes.xml as I said above and just set parent as android:Theme.Dialog. And added a line like this.
<item name="android:windowAnimationStyle">@android:style/Animation</item>
感谢您的帮助,我希望此解决方案可以帮助其他人.
Thanks for the help and I hope this solution helps others.
这篇关于如何始终将背景屏幕设置为墙纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!