I have struck with one problem how can i disable seekbar without dimming, i have tried all the method in this question which have a same doubt android disabled seekBar without dimming let me post what i have tried so far:
I have set
private SeekBar seekBar;
seekBar=(SeekBar)itemView.findViewById(R.id.seek);
seekBar.setEnabled(false);
seekBar.getProgressDrawable().setAlpha(255);
in xml:
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/mode"
android:maxHeight="5dp"
android:id="@+id/seek"
/>
Still this code doesn't make my seekbar brighter can anyone help me Thanks in advance!!
Try this one it works for me.
seekBar.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
As far as I know, a touch event will continue down the View
hierarchy (to views behind one another) until the last layer, unless it is suppressed by a return true
along the way. Thus, if we return true
within that code below, the touch event will stop and SeekBar
will not be seekable. If you want your View
to work again, you can return false
in your touch event.
boolean isSeekable; //true = enable, false = disable
seekBar.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
return !isSeekable;
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.