Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable changes on seekbar by client

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!

No given description by asker

like image 750
Shudy Avatar asked Apr 29 '13 16:04

Shudy


People also ask

How do I manage SeekBar on Android?

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.

What is SeekBar ProgressBar?

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.

How do I SeekBar progress?

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();

What is SeekBar discrete in Android Studio?

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.


1 Answers

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;  } }); 
like image 166
Srikanth P Avatar answered Sep 19 '22 15:09

Srikanth P