如何改变的多种活动的背景在同一时间? [英] How to change the background of multiple activities at the same time?
问题描述
我正在开发3活动的应用程序。每个活动都有相同的背景。我想使用户能够改变所有这三个活动的背景。所以我用一个AlertDialog提供用户多种选择。当用户点击对话框中的项目,背景将被改变。
I am developing an app with 3 activities. Every activity has the same background. I want to enable the users to change the background of all the three activities. So i used a AlertDialog to provide the user several choices. When the user click the items on the Dialog, the background will be changed.
我已经尝试实现这个功能上面的两种方法:
I have tried two ways of implementing this function above:
1)使用安卓主题在AndroidManifest.xml中。这果然奏效。但坏的事情是,所有的视图中的应用将扩大主题。我做了不相关的意见空的背景。但我不能在对话中删除扩展的主题。这使我的对话框非常难看。
1) use the Android:theme in AndroidManifest.XML. This really worked. But the bad thing was that all the View in the application will extend the theme. I made the background of unrelated views null. But i can not remove extended theme in the Dialog. This made my dialog very ugly.
2)我在这三个活动的布局XML应用风格。但问题是,我不能修改样式背景属性编程。
2) I applied 'style' in the layout xml of the three activity. But the problem is that i can not modify the background attribute in the style programmatically.
是否有人有一些想法来处理这个问题呢?谢谢!
Does someone have some idea to deal with this problem? thx!
推荐答案
有几个选项,但这里是2,我能想到的:
There are a couple of options, but here are 2 that I can think of:
-
创建自定义对话框,并覆盖,设置主题,以取消新的主题变化的方法。
Create a custom Dialog and override the method that sets the theme to cancel the change of the new theme.
请一个preference在应用程序preferences,指出选择的背景图片,然后将在活动开始每项活动的主要布局视图的背景。
Keep a preference in the application preferences that states the background image selected, then set the background of the main layout view of each activity when the activity is started.
这篇关于如何改变的多种活动的背景在同一时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!