I added a touch event to a linear layout to respond to swipe gestures, and it works well. However, when i add buttons to the layout, the parent liner layout is ignored. How should I prevent this from happening?
LinearLayout ln2 = (LinearLayout) findViewById(R.id.fr2);
ln2.setOnTouchListener(swipe);
How to i use onInterceptTouch
?
You should create your own layout and override onInterceptTouchEvent(MotionEvent ev) method of your layout.
For Example I created my own layout which extends RelativeLayout
And when i put a button to my layout, even i clicked that button, My Layout consumes all the touchEvent because of the
onInterceptTouchEvent
always returns true.Hope this should help you
Add android:onClick="tapEvent" in your layout which you want to take the click. By changing the MAX_TAP_COUNT value, you can use any number of taps.