To make clear , i want to prevent dragging at 80% of max value also left margin 20% . Dragging range will be (from 20% to the 80%) .
I just need to know is it possible make it from existing method clear and easy.
screenshot
To make clear , i want to prevent dragging at 80% of max value also left margin 20% . Dragging range will be (from 20% to the 80%) .
I just need to know is it possible make it from existing method clear and easy.
screenshot
You can do it with onProgressChanged
with a very basic calculations. If the min value is 0 and max value is 200 and we want to limit the first and last 20%. In the onProgressChanged
method you just:
// I think this two variables should be out of the method
int limit = ((20 * 200) / 100);
int maxValue = seekBar.getMax();
if(seekBar.getProgress() >= (maxValue - limit)){
seekBar.setProgress(maxValue);
}else if(seekBar.getProgress() <= limit){
seekBar.setProgress(limit);
}
This has been done on the fly, it isn't tested and probably there is something wrong, but that is the idea
as mentioned in the answer here regarding
You can't define the minimum value. It is 0.
If you want to set maximum value you can do it
by xml
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="your_max_value"/>
using java
seekBar = (SeekBar)findViewById(R.id.seekbar_id);
seekBar.setMax(your_max_value);