android - How to make seekbar like this -


i want apply effect seekbar shown below:

download it...

horizontal progress image

what have tried below.the complete code below try , let me know if effect below.

mainactivity.java

public class mainactivity extends activity  {   private static int myprogress=0;  private seekbar seekbar;  private int progressstatus=0;  private handler myhandler=new handler();  @override public void oncreate(bundle savedinstancestate)  {     super.oncreate(savedinstancestate);     setcontentview(r.layout.h_processbar);  }  public void beginyourtask(view view) {      myprogress=0;     seekbar= (seekbar)findviewbyid(r.id.seekbar);     seekbar.setmax(100);      new thread(new runnable() {          @override         public void run() {             // todo auto-generated method stub             while(progressstatus<100)             {                 progressstatus=performtask();                 myhandler.post(new runnable()                 {                 public void run() {                 seekbar.setprogress(progressstatus);                 }                 });              }             myhandler.post(new runnable() {                  @override                 public void run() {                     // todo auto-generated method stub                    toast.maketext(getbasecontext(),"task completed",toast.length_long).show();                    progressstatus=0;                     myprogress=0;                  }             });          }         private int performtask()         {             try {                 //---do task---                 thread.sleep(100);                 } catch (interruptedexception e)                 {                 e.printstacktrace();                 }                 return ++myprogress;             }     }).start();    }   } 

progress_horizontal_green.xml

<?xml version="1.0" encoding="utf-8"?> <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="#ff54e854"                     android:centercolor="#ff004900"                      android:endcolor="#ff54e854"                     android:angle="90"             />         </shape>     </clip>  </item>   </layer-list> 

h_processbar.xml

<button     android:id="@+id/button1"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:onclick="beginyourtask"     android:text="start task"      android:textcolor="#ffffff"     android:layout_margin="10dp"/>  <linearlayout     android:layout_width="290dp"    android:layout_height="wrap_content"    android:layout_gravity="center"    android:layout_margintop="30dp"    >          <seekbar             android:id="@+id/seekbar"             android:max="100"              android:progress="60"             android:layout_width="260dp"             android:layout_height="wrap_content"             android:thumb="@drawable/down_arrow_new"             android:progressdrawable="@drawable/progress_horizontal_green"             android:layout_margin="20dp"             />  </linearlayout> 

down_arrow_new.png here horizontal progress image download it...

as shown in figure lhs(left hand side) starts from dark green color , progress goes forward looks combination of light green shades blur effect.

and blur effect makes awesome.

how can achieve this?any idea?

any appreciated.

thank you.


Comments