title: Changing the size of the seekbar programmatically but cant get the thumb to be larger than the bar
body: <p>I have to make a seekbar where i can change almost everything programmatically. And now I'm having a problem to change the thumb and the bar size. Everything works great if the bar is larger or the same size as the thumb, but if the thumb is larger than the bar, I can't get it to show the entire thumb with the correct size of the bar. </p>
  
  <p>Here's my code to create the thumb:</p>
  
  <pre><code>   public void setSeekBarThumb(int width, int height, int rColor, int gColor, int bColor){
  
          ShapeDrawable thumb = new ShapeDrawable( new OvalShape() );
          thumb.setIntrinsicHeight( height );
          thumb.setIntrinsicWidth( width );
          thumb.setBounds(new Rect(0, 0, width, height));
  
  
          StateListDrawable states = new StateListDrawable();
          states.addState(new int[] {android.R.attr.state_pressed},thumb  );//add to the state list with the state pressed
  
          thumb = new ShapeDrawable( new OvalShape() );
          thumb.setIntrinsicHeight( height );
          thumb.setIntrinsicWidth( width );
          thumb.setBounds(new Rect(0, 0, width, height));
  
          states.addState(new int[] { },thumb );//add to the state list with no state
  
          seekbar.setThumb(states); 
          seekbar.setThumbOffset(0);
    }
  </code></pre>
  
  <p>heres my code to create the bar:</p>
  
  <pre><code>   public void setSeekBarProgress(int width, int height, int rColor, int gColor, int bColor){
          GradientDrawable shape = new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{Color.WHITE,Color.rgb(rColor, gColor, bColor)});
          shape.setCornerRadius(50);
          shape.setSize(width, height);
          shape.setBounds(0, 0, width, height);
          ClipDrawable clip = new ClipDrawable(shape, Gravity.LEFT,ClipDrawable.HORIZONTAL);
  
          shape = new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{Color.WHITE, getResources().getColor(R.color.DimGray)});
          shape.setCornerRadius(50);//change the corners of the rectangle 
          shape.setSize(width, height);
          shape.setBounds(0, 0, width, height);
  
          LayerDrawable mylayer= new LayerDrawable(new Drawable[]{shape, clip,});
  
          seekbar.setProgressDrawable(mylayer); 
          seekbar.setProgress(50);
  
    }
  </code></pre>
  
  <p>Here is my code to put everything together, where I set the height of the seek bar:</p>
  
  <pre><code>  public MySeekBar(Activity activity, AbsoluteLayout ParentLayout, SeekBarParameters parameters)
    {        
          super(activity.getApplicationContext());
  
  
  
          seekbar =(SeekBar)activity.getLayoutInflater().inflate(R.layout.horizontal_seek_bar, ParentLayout,false);
          seekbar.setMax(100);    
           setSeekBarThumb(parameters.widthThumb, parameters.heightThumb,0,100,0);
           setSeekBarProgress(parameters.width, parameters.height,255,69,0); 
  
           int drawHeight;
           if(parameters.height&gt;parameters.heightThumb) drawHeight=parameters.height;
           else drawHeight=parameters.heightThumb; 
  
          AbsoluteLayout.LayoutParams params = new   AsoluteLayout.LayoutParams(parameters.width,drawHeight,parameters.xPosition, parameters.yPosition);
          ParentLayout.addView(seekbar, params);                       
  
    }
  </code></pre>
  
  <p>The XML code where I inflate the bar from:</p>
  
  <pre><code>  &lt;SeekBar xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center"
        android:max="100"
        android:progress="0"
        android:secondaryProgress="0"
        android:maxHeight="10000dip"
        android:id="@+id/slider"
     /&gt;
  </code></pre>
  
  <p>To change the size of the seek bar I use  ParentLayout.addView(seekbar, params).<br>
  When adding the view, if I use the height that I want to the bar, the thumb gets cutted. If I use the height of the thumb, the bar gets to the same height of the thumb. Android resizes the bar to the size I use to add the view.<br>
  I tryed setting the size of the GradientDrawable that is the bar with s<code>hape.setSize(width, height)</code>, I also tried <code>shape.setBounds(0, 0, width, height)</code>, and I tried creating another image with the right size and adding to the LayerDrawable mylayer. But nothing worked.</p>
  
  <p>When creating this through XML it's possible to use <code>paddingTop</code> and <code>paddingBottom</code> to get the bar to the right size. But I don't know how to do this to the GradientDrawable programmatically. </p>