How to disable onTouch of parent retaining onTouch of child in android -
How to disable onTouch of parent retaining onTouch of child in android -
what having:
i havingimageview
on linear layout. want observe ontouch
of imageview
. i not want utilize onclick
because implementation requires ontouch imageview
kid of linearlayout what happening:
two touch events firing when click on image 1 image ,linear layout(parent)
question:
how can disableontouch
of linearlayout
(parent)retaining ontouch
of imageview
code:
@override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); imgusrclrid.setontouchlistener(imgsourceontouchlistener); } ontouchlistener imgsourceontouchlistener= new ontouchlistener(){ @override public boolean ontouch(view view, motionevent event) { log.d("", ""); homecoming true; }};
touch event fired 1 view @ time, , here in code touch event fired imageview know touchlistener called every motionevent.action_down, motionevent.action_up, , motionevent.action_move . if want 1 event fired @ time , ie motionevent.action_down or motionevent.action_up write in way:
@override public boolean ontouchevent(motionevent ev) {
final int action = ev.getaction(); switch (action) { // motionevent class constant signifying finger-down event case motionevent.action_down: { //your code break; } // motionevent class constant signifying finger-drag event case motionevent.action_move: { //your code break; } // motionevent class constant signifying finger-up event case motionevent.action_up: //your code break; } homecoming true; }
android android-layout ontouchlistener
Comments
Post a Comment