I need to change the color in the application bar to some gradient color. I created the action_bar_bg.xml file in a transferable folder:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:centerColor="@color/colorPrimaryDark"
android:endColor="@color/colorPrimary"
android:startColor="@color/colorPrimary" />
</shape>
and I tried changing colorPrimary to styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@drawable/action_bar_bg</item>
</style>
but that will not work. I get the error: android.content.res.Resources$NotFoundException: File res/drawable/action_bar_bg.xml from color state list resource ID #0x7f020046)
I want to achieve this result:

What do I need to change in the code?
source
share