Using the Appcompat support library (and AppCompatActivity)
Light Status Bar (API 23+)
This attribute can change the background of the Status Bar icons (at the top of the screen) to white.
Multiple Themes in one App
Using more than one theme in your Android application, you can add custom colors to every theme, to be like this:
First, we have to add our themes to style.xml like this:
Above you can see OneTheme and TwoTheme.
Now, go to your AndroidManifest.xml and add this line:
android:theme="@style/OneTheme" to your application tag, this will make OneTheme the default theme:
Create new xml file named attrs.xml and add this code :
Go back to style.xml and add these colors with its values for each theme :
Now you have custom colors for each theme, let's add these color to our views.
Add custom_blue color to the TextView by using "?attr/" :
Go to your imageView and add this color :
Mow we can change the theme just by single line setTheme(R.style.TwoTheme); this line must be before setContentView() method in onCreate() method, like this Activity.java :
change theme for all activities at once
If we want to change the theme for all activities, we have to create new class named MyActivity extends AppCompatActivity class (or Activity class) and add line setTheme(R.style.TwoTheme); to onCreate() method:
Finally, go to all your activities add make all of them extend the MyActivity base class:
In order to change the theme, just go to MyActivity and change R.style.TwoTheme to your theme (R.style.OneTheme , R.style.ThreeTheme ....).
Navigation Bar Color (API 21+)
This attribute is used to change the navigation bar (one, that contain Back, Home Recent button). Usually it is black, however it's color can be changed.
Overscroll Color (API 21+)
Ripple Color (API 21+)
The ripple animation is shown when user presses clickable views.
You can use the same ripple color used by your app assigning the ?android:colorControlHighlight in your views. You can customize this color by changing the android:colorControlHighlight attribute in your theme:
This effect color can be changed:
Or, if you are using a Material Theme:
When defining themes, one usually uses the theme provided by the system, and then changes modifies the look to fit his own application. For example, this is how the Theme.AppCompat theme is inherited:
This theme now has all the properties of the standard Theme.AppCompat theme, except the ones we explicitly changed.
There is also a shortcut when inheriting, usually used when one inherits from his own theme:
Since it already has AppTheme. in the start of it's name, it automatically inherits it, without needing to define the parent theme. This is useful when you need to create specific styles for a part (for example, a single Activity) of your app.
Translucent Navigation and Status Bars (API 19+)
The navigation bar (at the bottom of the screen) can be transparent. Here is the way to achieve it.
The Status Bar (top of the screen) can be made transparent, by applying this attribute to the style:
Use Custom Theme Globally
Use Custom Theme Per Activity
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0