android - Check Touch out of relative layout -


i want check touch x,y position in activity know out of relativelayout or not. override ontouchevent activity not working fine.

you have this.. in activity have override

dispatchtouchevent 

so in oncreate find view

relativelayout  yourlayout = (relativelayout) findviewbyid(r.id.yourlayout); 

and

@override public boolean dispatchtouchevent(motionevent ev) {          float touchpointx = ev.getx();         float touchpointy = ev.gety();         int[] coordinates = new int[2];         yourlayout.getlocationonscreen(coordinates);         if (touchpointx < coordinates[0] || touchpointx > coordinates[0] + yourlayout.getwidth() || touchpointy < coordinates[1] || touchpointy > coordinates[1] + yourlayout.getheight()){             //do action    }     return super.dispatchtouchevent(ev);     } 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -