[![Picture of seekbar](https://i.stack.imgur.com/963iN.png)](https://i.stack.imgur.com/963iN.png)

I managed to create the seekbar programmatically in android, but am stuck at centering the rectangular thumb and adjusting it's height properly. How do I center the thumb?

EDIT : Attaching the code 
Note : the code is in javascript, but it is equivalent to what could be done in java (I am using an environment wherein it can be done)

```
function setSeekBarProgress(){

    var shape=new android.graphics.drawable.GradientDrawable();
    shape.setOrientation(android.graphics.drawable.GradientDrawable.Orientation.BOTTOM_TOP);
    shape.setColor(android.graphics.Color.BLUE);
    shape.setCornerRadius(50);
    shape.setSize(600,200);
    shape.setBounds(0,0,600,200);

    var clip=new android.graphics.drawable.ClipDrawable(shape,android.view.Gravity.LEFT,android.graphics.drawable.ClipDrawable.HORIZONTAL);

    shape=new android.graphics.drawable.GradientDrawable();
    shape.setOrientation(android.graphics.drawable.GradientDrawable.Orientation.BOTTOM_TOP);
    shape.setColor(android.graphics.Color.BLACK);

    shape.setCornerRadius(50);
    shape.setSize(1000,200);
    shape.setBounds(0,0,1000,200);
    var insetDrawable=new android.graphics.drawable.InsetDrawable(shape,5,5,5,5);

    var a=[];
    var drawableArray= java.lang.reflect.Array.newInstance(android.graphics.drawable.Drawable.class,2);
    drawableArray[0]=insetDrawable;
    drawableArray[1]=clip;

    var myLayer = new android.graphics.drawable.LayerDrawable(drawableArray);

    nativeSeekBar.setProgressDrawable(myLayer);

}

```

And the code to create seekbar :

```
           nativeSeekBar=new android.widget.SeekBar(args.context,null, android.R.attr.progressBarStyleHorizontal);
            setSeekBarProgress();
            var RoundRecFirstArg= java.lang.reflect.Array.newInstance(java.lang.Float.class.getField("TYPE").get(null),8);
            RoundRecFirstArg[0]=2;
            RoundRecFirstArg[1]=2;
            RoundRecFirstArg[2]=2;
            RoundRecFirstArg[3]=2;
            RoundRecFirstArg[4]=2;
            RoundRecFirstArg[5]=2;
            RoundRecFirstArg[6]=2;
            RoundRecFirstArg[7]=2;
            var thumb=new android.graphics.drawable.ShapeDrawable(new android.graphics.drawable.shapes.RoundRectShape(RoundRecFirstArg,null,null));
                           thumb.getPaint().setColor(android.graphics.Color.rgb(133,133,133));
            thumb.setIntrinsicHeight(200);
            thumb.setIntrinsicWidth(80);
            nativeSeekBar.setThumb(thumb);
            nativeSeekBar.setProgress(20);

```