如何设置最小进度搜索栏?

How to set Minimum progress seekbar?

我有这段代码可以使用 seekbar 制作一些编辑器文本和自定义字体大小,如何为 int progres seekbar 设置最小值?

seekerFont.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        fontsize.setText(""+ progress);
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {

    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {

    }
});
eekerFont.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
    int progressChanged = minimumValue;

    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        progressChanged = minimumValue+ progress;
    }
});

Link: Android SeekBar Minimum Value

您可以设置最小或最大进度

eekerFont.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){   

public void onStopTrackingTouch(SeekBar seekBar) {

//TODO My code goes here

int CurrentLevel = eekerFont.getProgress();
if (CurrentLevel < 30) CurrentLevel = 30;
eekerFont.setProgress(CurrentLevel);

}

public void onStartTrackingTouch(SeekBar seekBar){

}

public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser){
}});

在XML也可以设置

android:progress="10"

另一种更好的方法是使用很少的逻辑,例如你想将值设置在 50 到 100 之间。然后这样做

seekBar.setMax(50);
int selectedProgress = seekBar.getProgress() + 50; // or in change listener