Hello,
Please use Theme.MaterialComponents.Light.NoActionBar
to your app default theme, then create a custom theme that extend the Theme.AppCompat.Light.NoActionBar
in your styles.xml
like following code.
<style name="AppTheme" parent="Theme.MaterialComponents.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>
<style name="MyCustomTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#ff0000</item>
<item name="colorPrimaryDark">#ff0000</item>
<item name="colorAccent">#ff0000</item>
</style>
If I have a button that need to set the MyCustomTheme
, I can use following theme.
<Button
android:layout_column="0" android:layout_row="4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MyCustomTheme"
android:text="click"/>
You can refer to this document about android Material themes
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.