How to set seekbar min and max value

前端 未结 14 826
栀梦
栀梦 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:59

    Set seekbar max and min value

    seekbar have method that setmax(int position) and setProgress(int position)
    

    thanks

    0 讨论(0)
  • 2020-11-28 09:59
        paySeekRange.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                Debug.i(TAG, "onProgressChanged 1: " + progress);
                int progressMin = (progress * (maxPayRange - minPayRange) / 100) + minPayRange;
                Debug.i(TAG, "onProgressChanged 2: " + progress);
                int progressMax = (progress * (maxPayRange) / 100);
                progress = (progress * (progressMax - progressMin) / 100) + progressMin;
                Debug.i(TAG, "onProgressChanged 3: " + progress);
                txtWeeklyPay.setText("$".concat(String.valueOf(progress)));
            }
    
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
    
            }
    
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
    
            }
        });
    
    0 讨论(0)
提交回复
热议问题