I have a SeekBar that will change the progress when I require it to, but I don't want the user to be able to change it manually.
I tried to set the SeekBar as this:
<SeekBar android:id="@+id/seekBar1" android:layout_width="match_parent" android:layout_height="65dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="78dp" android:progress="10" android:max="100" android:clickable="false" android:thumb="@drawable/transparent" android:progressDrawable="@drawable/customprogressbar" />
But it doesn't work.
How can I do this?
That's more or less an example of how this is going to be seen by the client.
I used a custom style because in the future I'll need to change the background images and the progress depending on which section the SeekBar will be.
Thanks for all!
Below are the steps for Creating SeekBar Android Application: Step1: Create a new project. After that, you will have java and XML file. Step2: Open your xml file and add a SeekBar and TextView for message as shown below, max attribute in SeekBar define the maximum it can take.
A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged.
You are looking for the method getProgress() of the ProgressBar class as SeekBar is a subclass of ProgressBar . So basically it would be something like that. int value = seekBar. getProgress();
In Android Discrete SeekBar is just an advancement of progressBar just like the SeekBar, the only difference in SeekBar and discrete SeekBar being that in discrete SeekBar, we can only set the value only to discrete values like 1, 2, 3, and so on.
You can use android:enabled="false" , but it will display disable effect [darken your seekbar].
So if you want to display enable seekbar with no response to thumb activity, implement touch event handler with return true as shown below.
seekBar.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { return true; } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With