In Android development, we can customize the interface theme by controlling the value of the attribute and changing the color of the interface
colorPrimary—navigation bar color
colorPrimaryDark—notification bar color
colorAccent—the color after the control is selected
The code example is given below
1. In the style.xml file, customize the theme AppTheme.White
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- AppTheme.White -->
<style name="AppTheme.White" parent="@style/AppTheme">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
2. Use this theme in AndroidManifest, xml, and give some screenshots of the file
Here are some introductions:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
A theme called AppTheme is defined here, and its parent theme is specified as Theme.AppCompat.Light.DarkActionBar. This DarkActionBar is a dark ActionBar theme. The ActionBar that came with all our previous projects appeared because of this theme.
Usually there are two themes, Theme.AppCompat.NoActionBar and Theme.AppCompat.Light.NoActionBar. Among them, Theme.AppCompat.NoActionBar represents a dark theme, which will set the main color of the interface to a dark color, and set the foil color to a light color. And Theme.AppCompat.Light.NoActionBar represents a light theme, which will set the main color of the interface to a light color, and set the foil color to a dark color
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>