title: Android seekbar with custom thumb having dynamic text inside it
body: <p>I want to create android custom <code>SeekBar</code> having <em>thumb with text</em> inside it to show current seek position.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>SeekBar sb;
  
  @Override
  public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.custom_seek_bar_activity);
  
      sb = (SeekBar)findViewById(R.id.slider);
      sb.setMax(100);
      sb.setProgress(10);
      BitmapDrawable bd = writeOnDrawable(R.drawable.star2, Double.toString(50));
  
      sb.setThumb(bd);
  
      sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
          {
              int pos = sb.getProgress();
              double star = pos/(20.0);
              TextView tv = (TextView)findViewById(R.id.percent);
              tv.setText(Double.toString(star)+"%");
              BitmapDrawable bd = writeOnDrawable(R.drawable.star2, Double.toString(star));
              bd.setBounds(new Rect(0,0, 
                  bd.getIntrinsicWidth(), 
                  bd.getIntrinsicHeight()
              ));
              seekBar.setThumb(bd);
          }
  
          @Override
          public void onStartTrackingTouch(SeekBar arg0) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onStopTrackingTouch(SeekBar arg0) {
              // TODO Auto-generated method stub
  
          }
      });
  
  }   
  
  public BitmapDrawable writeOnDrawable(int drawableId, String text){
  
      Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId).copy(Bitmap.Config.ARGB_8888, true);
  
      Paint paint = new Paint(); 
      paint.setStyle(Style.FILL);  
      paint.setColor(Color.BLACK); 
      paint.setTextSize(10); 
  
      Canvas canvas = new Canvas(bm);
      canvas.drawText(text, 0, bm.getHeight()/2, paint);
  
      return new BitmapDrawable(bm);
  }
  </code></pre>
  
  <p>but when I move thumb it goes to the beginning of the seek bar.
  Does anyone have solution to move custom thumb with seekbar position?</p>