Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

android - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...