问题
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.
回答1:
add this proprety
android:progress="2"
回答2:
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);
回答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
回答4:
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>);
回答5:
You can add this: android:rotation="180" to the XML and then the seekbar will flip the way you want
回答6:
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();
}
});
}
来源:https://stackoverflow.com/questions/7805450/how-to-change-android-seekbar-track-start-position