13

I'd like to set the SeekBars's track start position so it does not start from the left side of the seekbar, but form an arbitrary position. Here is a photoshop image how it should look like:

http://i.imgur.com/QCMEu.png

It should be just a graphical effect, the SeekBar's underlying logic is not changed.

I tried to change the Seekbar.getprogressDrawable.SetBounds() to change the track image position, but no luck.

Machavity
  • 30,841
  • 27
  • 92
  • 100
user1000594
  • 131
  • 1
  • 1
  • 5

6 Answers6

10

add this proprety

 android:progress="2" 
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
  • Hi, thanks for the reply. I`d like to set the start position of the track line, not the seeekbar`s thumb. As you can see in the image (http://i.imgur.com/QCMEu.png) the seekbar`s track does not start at the far left of the seekbar, but starts form the first quarter of the seekbar. I`d like to acheve that effect. – user1000594 Oct 18 '11 at 11:23
  • u want arrange seek from middle. or desired position . – RajaReddy PolamReddy Oct 18 '11 at 11:48
8

You can set progress of SeekBar in xml as:

android:progress="10"
android:max="90" <!-- maximum seekbar progress -->

you can programmatically set the progress of SeekBar as:

seekBar.setProgress(10);
Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
3

May be your problem is similar to Seekbar for two values [-50, 0, 50].

Thanks to Commonsware to point to right direction. I wrote a class inspired by code.google.com/p/range-seek-bar) to get the solution.

https://github.com/vashisthg/StartPointSeekBar

Community
  • 1
  • 1
Gaurav Vashisth
  • 7,547
  • 8
  • 35
  • 56
1

By Programatically,we can start the progress and set the maximum of seekbar progress.

//start from <starting value>
seekBar.setProgress(<strating_value>);

//Set to maximum Value<max_value>
seekBar.setMax(<max_value>);
Dhasneem
  • 4,037
  • 4
  • 33
  • 47
1

You can add this: android:rotation="180" to the XML and then the seekbar will flip the way you want

0

Just faced the same problem. That's how I have solved it.

Assume, we need seekbar starting from 10 and ending at 150.

@Override
    protected void onCreate(Bundle savedInstanceState)
    {...
     yourSpinner = (Spinner) findViewById(R.id.your_spinner);
     yourSpinner.setMax(150 - 10);

     int newProgress;

     yourSpinner.setOnSeekBarChangeListener(new   SeekBar.OnSeekBarChangeListener()
        {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
            {
                newProgress= 10 + progress;

                Toast.makeText(getApplicationContext(), String.valueOf(newProgress), Toast.LENGTH_LONG).show();
            }
        });
    }