Egor Egor - 1 year ago 135
Android Question

Android SeekBar strange behaviour

I have a default SeekBar in Android with 3 possible values: 0,1,2 (left, middle, right).

But it takes some value only when finger is exactly on the point(corresponding to the value) or to the right of it. If the finger is even 1 pixel left of the point, seekbar takes previous value.

I want it to take value when finger is near the point.
My explanation skill is very poor, so see the picture:

Answer Source

If using 3 points isn't enough, why not add more points and map back to your 3? e.g.

private static final double RATIOS = new double[]{ .33, 66, 100 }
private static final int FAKED_POINTS = new int[]{ 0, 50, 100 }

private void setupSeekBar() {
    // Your normal setup

public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if(!fromUser) // We only want to do this when the user changes the values

    for(int i = 0; i < RATIOS.length; i++){
        if(progress <= RATIOS[i]){

            seekBar.setProgress(FAKED_POINTS[i]); //  This way it always stays on our 3 faked points

private void onRealProgressChanged(int realProgress){
    // Deal with the real changed value (being 0, 1, or 2)

If you need even more fine-tuning, you can scale that up another order of magnitude.

Not very clean or pretty, but should point you in the right direction.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download