Search code examples
javaandroidandroid-studioseekbar

How do I change the format of my SeekBar?


I am beginner student in Java and android studio. I am trying to make a seekbar that gives both negative and positive values. I managed to make a seekbar as shown in the picture [1]: https://i.sstatic.net/tJZJN.png). However it start at 0 and finishes at 100. I would like it to start at -50 and finishes at 50. the code I have is right here. Hopfully someone can help .

thank you in advance. Here is my code

public class MainActivity extends AppCompatActivity {

ArcSeekBar defaultSeekBar, seekBarBackground, gradientSeekBar;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);




    defaultSeekBar= (ArcSeekBar) findViewById (R.id.defaultSeekBar );


    defaultSeekBar.setOnProgressChangedListener(new ProgressListener() {
        @Override
        public void invoke(int i) {
            Log.d("VALUE",""+i);

        }
    });


}

}


Solution

  • Wouldn't that be setMin(x) and setMax(x) ? In addition to doing this programmatically you could also apply it within the layout itself.

    Refer to (bookmark this site and always explore what APIs exist within the class you are using):

    https://developer.android.com/reference/android/widget/AbsSeekBar?hl=en#setMax(int)