We all know that Android is Seekbar, when your finger is sliding on the Seekbar, Seekbar's progress bar will always go with your finger, but in some cases you may find it tricky to disable Seekbar.
In fact, we see the Seekbar class itself does not rewrite the Ontouchevent event, then continue to find its parent class Absseekbar, we see Ontouchevent is rewritten in Absseekbar, write the content we do not care about, We know that Ontouchevent was distributed in dispatchtouchevent, and we looked directly at the dispatchtouchevent of the view:
PublicBoolean dispatchtouchevent (motioneventEvent) { if(Minputeventconsistencyverifier! =NULL) {minputeventconsistencyverifier.ontouchevent (Event,0); } if(Onfiltertoucheventforsecurity (Event)) { //noinspection simplifiableifstatementListenerinfo Li =Mlistenerinfo; if(Li! =NULL&&Li.montouchlistener! = null && (Mviewflags & enabled_mask) = =ENABLED&&Li.mOnTouchListener.onTouch (This, event )) { return true; } if(Ontouchevent (Event)) { return true; } } if(Minputeventconsistencyverifier! =NULL) {minputeventconsistencyverifier.onunhandledevent (Event,0); } return false; }
We look at the fact that as long as li.montouchlistener! = null&& Li.mOnTouchListener.onTouch (this, the event) This judgment is established, Indicates that the Outouch event has been digested by this component, no longer distributed, the judgment is not established, will continue to judge if (Ontouchevent (event)) this sentence.
Then we recall Seekbar touch process, when you touch the Seekbar, Seekbar go first to call Inherit view Dispatchtouchevent .... And what if we don't want to make the Seekbar itself ontouchevent?
Of course, it's bound to seekbar a ontouchlistener and returns true.
If you want the touchevent of Seekbar itself to be set up, bind a ontouchlistener to Seekbar and return false to Meow
>_<
How Android blocks Seekbar Touch events