Pial Kanti
Pial Kanti

Reputation: 1610

Creating a Dark background Theme in android

I am making a option for user to choose themes from two themes.Actually i use AppTheme as app default theme.There a option for user to switch between two themes Light and Dark. When user chooses Dark theme it should change to MyThemeDark from default theme Apptheme .

My style.xml is

 <style name="AppTheme" parent="AppTheme.Base"></style>

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">#009688</item>
</style>

<style name="MyThemeDark" parent="MyTheme.Dark"></style>

<style name="MyTheme.Dark" parent="Theme.AppCompat">
    <item name="colorPrimary">#009688</item>
    <item name="android:windowBackground">@color/Background</item>
    <item name="android:colorBackground">@color/Background</item>
</style>

And in color.xml

<color name="Background">#363F45</color>

in my AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

Themes are changing correctly.But my problem is while changing to MyThemeDark the background color is not changing to dark color rather it remains white. How can i fix this problem?

I want theme like this photo

https://goo.gl/photos/F95fm7NQWCGGNa9g6

Upvotes: 0

Views: 1898

Answers (1)

user5328529
user5328529

Reputation:

You can use this command in XML file, within layout tag to change color it so simple for example for Relative layout:

<Relativelayout
android:background="#000000"> </Relativelayout>

Also, You can use simple color resources, specified usually inside res/values/colors.xml

<color
name="red">#ffff0000</color>

or get it in code via:

getResources().getColor(R.color.red)

Upvotes: 1

Related Questions