更新时间:2021-09-09 21:35:33
使用安卓colorPrimary
。 colorPrimary
自己才会如果你是从 Theme.AppCompat
继承工作。
Use android:colorPrimary
. colorPrimary
on its own will only work if you are inheriting from Theme.AppCompat
.
因此,例如,在此示例项目,我有:
So, for example, in this sample project, I have:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Apptheme" parent="android:Theme.Material">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>