Disable changes on seekbar by client

Shudy picture Shudy · Apr 29, 2013 · Viewed 30.5k times · Source

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

Answer

Srikanth P picture Srikanth P · Jan 5, 2015

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