how to limit seekbar

前端 未结 6 593
别那么骄傲
别那么骄傲 2020-12-29 02:10

I\'d like to set max and minimum limits of SeekBar to 50 and 20 respectively.

SeekBar has a direct option top provide max value, but how to set its

6条回答
  •  时光取名叫无心
    2020-12-29 02:38

    In SeekBar you can set only max value.

    
    

    And, You cannot directly set the minimum value to the seekbar.

     SeekBar mSeekbar = (SeekBar) findViewById(R.id.SeekBar01);
    
        mSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
        {
           public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
           {
                length_edit.setText(Integer.toString(progress + 20));
           }
    
          public void onStartTrackingTouch(SeekBar seekBar) {}
    
          public void onStopTrackingTouch(SeekBar seekBar) {}
        });
    

    As you see min progress you can sum with min which I would like - in your case 20.

提交回复
热议问题