android - How to set progressbar background -


i have set progressbar style using below code.

i have declared progressbar widget:

 <progressbar     android:id="@+id/loadprogress"     style="?android:attr/progressbarstylehorizontal"     android:layout_width="match_parent"     android:layout_height="20dip"     android:max="100"     android:progressdrawable="@drawable/load_progress"     android:progress="0" /> 

defined "@drawable/load_progress"

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >  <item     android:id="@android:id/background"     android:drawable="@drawable/background_bk"> </item> <item     android:id="@android:id/progress"     android:drawable="@drawable/progress_bk"> </item>  </layer-list> 

defined "@drawable/background_bk" (it red)

<?xml version="1.0" encoding="utf-8"?>  <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >  <gradient     android:angle="0"     android:endcolor="#ff0000"     android:startcolor="#ff0990" />  <stroke     android:width="1dp"     android:color="#ff0000" />   </shape> 

defined @drawable/progress_bk (it green)

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >  <gradient     android:angle="0"     android:endcolor="#00ff00"     android:startcolor="#00ff00" />  <stroke     android:width="1dp"     android:color="#00ff00" />  </shape> 

the progressbar shows totally green (which how should appear when progress value 100), if set progress value less 100. input appreciated.

finally, find easy solution.

1

you can find default drawable xml file in folder "sdk_path\platforms\android19\data\res\drawable" overthere can find many default style of many widgets.

2

and file "progress_horizontal.xml". codes in file is:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  <item android:id="@android:id/background">     <shape>         <corners android:radius="5dip" />         <gradient                 android:startcolor="#ff9d9e9d"                 android:centercolor="#ff5a5d5a"                 android:centery="0.75"                 android:endcolor="#ff747674"                 android:angle="270"         />     </shape> </item>  <item android:id="@android:id/secondaryprogress">     <clip>         <shape>             <corners android:radius="5dip" />             <gradient                     android:startcolor="#80ffd300"                     android:centercolor="#80ffb600"                     android:centery="0.75"                     android:endcolor="#a0ffcb00"                     android:angle="270"             />         </shape>     </clip> </item>  <item android:id="@android:id/progress">     <clip>         <shape>             <corners android:radius="5dip" />             <gradient                     android:startcolor="#ffffd300"                     android:centercolor="#ffffb600"                     android:centery="0.75"                     android:endcolor="#ffffcb00"                     android:angle="270"             />         </shape>     </clip> </item>  </layer-list> 

3

you can change color of "progress color" , "background color".


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -