android - Custom (gradient) background of ActionBar Compat -


i using action bar compat action bar navigation drawer backward compatible down api level 9 , want change background of action bar.

i copied code android developers:

<?xml version="1.0" encoding="utf-8"?> <resources> <!-- theme applied application or activity --> <style name="customactionbartheme"        parent="@style/theme.appcompat.light.darkactionbar">     <item name="android:actionbarstyle">@style/myactionbar</item>      <!-- support library compatibility -->     <item name="actionbarstyle">@style/myactionbar</item> </style>  <!-- actionbar styles --> <style name="myactionbar"        parent="@style/widget.appcompat.light.actionbar.solid.inverse">     <item name="android:background">@drawable/actionbar_background</item>      <!-- support library compatibility -->     <item name="background">@drawable/actionbar_background</item> </style> </resources> 

and here comes problem.

when put image drawable or color background, works fine. want define background gradient shape, actionbar_background looks like:

<?xml version="1.0" encoding="utf-8"?> <shape     xmlns:android="http://schemas.android.com/apk/res/android"     android:shape="line"> <gradient         android:startcolor="@color/ac_bg_start"         android:endcolor="@color/ac_bg_end"         android:type="linear"/> <size         android:width="1dp"         android:height="48dp"/> </shape> 

i want repeated in horizontal way results in error, in fact, interesting error. test device , emulator gets restarted when try run app. able catch deadobjectexception before restarting.

how should background drawable like?

i working on same task.

here action_bar_bg.xml file in define gradient action bar.

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android">     <gradient         android:angle="90"         android:centercolor="@color/turquoise_action_bar"         android:endcolor="@color/dark_turquoise"         android:startcolor="@color/dark_turquoise" /> </shape> 

deadobjectexception

android:shape="line" can't used if there gradient inside. tested it; samsung galaxy note 10.1 n8000 restarted, , there deadobjectexception.

the linear type of gradient pattern default value. don't have declare explicitly.

here styles.xml in values folder.

<resources>      <!-- base application theme. -->     <style name="appthemebase" parent="theme.appcompat.light.darkactionbar">         <item name="android:actionbarstyle">@style/peoplecanact</item>         <!-- support library compatibility -->         <item name="actionbarstyle">@style/myactionbar</item>     </style>      <style name="apptheme" parent="appthemebase">         <!-- customizations not specific particular api level can go here -->     </style>      <!-- actionbar styles -->     <style name="myactionbar" parent="@style/widget.appcompat.light.actionbar.solid.inverse">         <item name="android:background">@drawable/action_bar_bg</item>         <!-- support library compatibility -->         <item name="background">@drawable/action_bar_bg</item>     </style>  </resources> 

gradient drawable


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -