0

I am using a seekbar. and I want to control it only by moving the thumb.

How can I disable the click on the progressdrawable?

I tried android:clickable="false" but it didn't work.

my seek Bar code in XML

      <SeekBar
        android:id="@+id/myseek"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:maxHeight="500dp"
        android:minHeight="50dp"
        android:paddingBottom="30dp"
        android:progressDrawable="@drawable/progress_left"
        android:thumb="@drawable/left_unlocker_bkg" >
    </SeekBar>

My Seekbar code for onSeekChangedListner

unlockSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar) {
                        toastText.setVisibility(View.GONE);
                        seekBar.setProgress(0);
                    }

                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {

                        if (seekBar.getProgress() < 10) {
                            seekBar.setProgress(0);
                        }
                        toastText.setVisibility(View.VISIBLE);
                        toastText.setText("Slide to Unclock");
                    }

                    @Override
                    public void onProgressChanged(SeekBar seekBar,
                            int progress, boolean fromUser) {

                        if (progress == 100) {
                            Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                            v.vibrate(100);
                            finish();
                        } 
                    }
                });

Currently, the user can click on the progress and the thumb moves I want to DISABLE it . Please help

Srikanth Pai
  • 926
  • 3
  • 17
  • 30

2 Answers2

6

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;
 }
});
Srikanth P
  • 1,506
  • 14
  • 12
0

You need to handle touch event of the seekbar. I think below link will be helpful to you.

Android seekbar solution

Community
  • 1
  • 1
Himanshu Dudhat
  • 1,609
  • 3
  • 14
  • 27