How to set seekbar min and max value

前端 未结 14 873
栀梦
栀梦 2020-11-28 09:17

I have a seekbar and trying to set the value from 60 to 180 for one and 40 to 190 for the second one in step of 1.

sb1 = (SeekBar) findViewById(R.id.progress         


        
14条回答
  •  [愿得一人]
    2020-11-28 09:58

    Seek Bar has methods for setting max values but not for setting min value here i write a code for setting minimum seek bar value when we add this code then your seek bar values not less then mim value try this its work fine for me

    /* This methods call after seek bar value change */

                public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {
                /* Check the current seekbar value is greather than min value*/
                if (progress < MIN_VALUE) {
                    /* if seek bar value is lesser than min value then set min value to seek bar */
                    seekBar.setProgress(MIN_VALUE);
                }
    
            }
    

提交回复
热议问题