android tutorial - Apply an appCompat theme in android - android studio - android app developement
The AppCompat support library provides themes to build apps with the Material Design specification. A theme with a parent of Theme.AppCompat is also required for an Activity to extend AppCompatActivity. The first step is to customize your theme’s color palette to automatically colorize your app. In your app's res/styles.xml you can define:
- Instead of Theme.AppCompat, which has a dark background, you can also use Theme.AppCompat.Light or Theme.AppCompat.Light.DarkActionBar.
- You can customize the theme with your own colours.
- Good choices are in the Material design specification colour chart, and Material Palette.
- The "500" colours are good choices for primary (blue 500 in this example); choose "700" of the same hue for the dark one; and an a shade from a different hue as the accent colour.
- The primary colour is used for your app's toolbar and its entry in the overview (recent apps) screen, the darker variant to tint the status bar, and the accent colour to highlight some controls.
- After creating this theme, apply it to your app in the AndroidManifest.xml and also apply the theme to any particular activity.
- This is useful for applying a AppTheme.NoActionBar theme, which lets you implement non-default toolbar configurations.
You can also apply themes to individual Views using android:theme and a ThemeOverlay theme. For example with a Toolbar: