2014-04-24 17 views
0

我正在創建一個應用程序,我找不到如何在應用程序的一個活動中選擇一種顏色,並讓它更改應用程序中所有其他活動的背景。我正在使用android studio。如何創建更改應用程序中所有活動背景的首選項?

以下是我的偏好設置屏幕中的代碼。我想知道需要添加什麼。

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/bkgcolor" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".SetActivity" > 

</PreferenceScreen>

+1

讓我們看看一些代碼! – Idris

+0

你想看什麼代碼? – user3566841

+0

與您的問題相關的代碼... – Idris

回答

0

最好的辦法是確定一個主題,並選擇其中之一。

你必須把此行的元素,你想在你的文件styles.xml使用一個主題

android:theme="@style/PreferencesTheme" 

做這樣的事情。

<style name="PreferencesTheme"> 
    <item name="android:windowBackground">@drawable/background_image</item> 
    <item name="android:background">#FFEAEAEA</item> 
</style> 

要檢查什麼主題,實現您可以使用sharedpreference救什麼主題都全光照,直到用戶關閉應用程序。

http://developer.android.com/reference/android/content/SharedPreferences.html

相關問題