How to make the seekbar thumb not exceed the progress margin?

51 Views Asked by At

When creating my custom seekBar I'm having problems, because the thumb is exceeding the progress bar of the seekBar, I would like the thumb to reach the end of the seekbar margin without exceeding it, Problem:

Problem

I wanted the thumb not to go beyond the progress bar of the seekbar just touching its margin. E.g.:

Example 1

Example 2

Linear code of seekbar:

LinearLayout linearLayout = new LinearLayout(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, dp(30));
linearLayout.setPadding(5, 5, 0, 5);       
layoutParams.setMargins(dp(3), dp(1), dp(2), dp(4));       
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setGravity(Gravity.CENTER);       linearLayout.setBackgroundColor(Color.parseColor("#000000"));
linearLayout.getBackground().setAlpha(1);
linearLayout.setLayoutParams(layoutParams);

Code of seekbar:

        seekBar.setProgressDrawable(seekbarProgressOff);
        seekBar.setPadding(25, 10, 35, 10);
        seekBar.setSplitTrack(false);
        seekBar.setLayoutParams(new LinearLayout.LayoutParams(-1, dp(18)));
        seekBar.setMax(max);
        seekBar.setProgress(prog);
        seekBar.setElevation(0);
        seekBar.setProgressDrawable(seekbarProgressOff);
        seekBar.setPadding(25, 10, 35, 10);
        seekBar.setSplitTrack(false);
        seekBar.setLayoutParams(new LinearLayout.LayoutParams(-1, dp(18)));
        seekBar.setMax(max);
        seekBar.setProgress(prog);
        seekBar.setElevation(0);

Thanks for help.

0

There are 0 best solutions below