Question

I am creating an app and I can't find out how to have a color selected in one activity in the app and have it change the background of all of the other activities in the app. I am using android studio.

Here is the code from my preferences screen. I would like to know what needs to be added.

<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>

Was it helpful?

Solution

The best way is define a theme and select one of them.

You have to put this line in the element you want to use a theme

android:theme="@style/PreferencesTheme"

in your file styles.xml do something like that.

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

To check what theme implement you can use a sharedpreference to save what theme are usin until the user close the app.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top