Do click throughs

I do not find a way to make this work.

My application has 2 FrameLayouts with many child views (suppose ImageViews are for simplicity) stacked on top of each other.

My problem is that I need FrameLayout in TOP and ALL CHILDREN to allow them to go through them, reaching the base FrameLayout (and its children). Something like event pointers: none in HTML apply to all TOP framelayout images.

I tried setClickable (false) and setEnabled (false) on both FrameLayout and its children, but if I click on disabled children (like ImageView), the touch won't reach the underlying ImageView (i.e. the child bottom frame of FrameLayout)

The following code is my best attempt to disable FrameLayout and its children (mSlideLayout is the parent layer of FrameLayout, each of them for each image). Did I miss something?

/** Create the layers structure into the layout */ void create_layers() { Context context=getActivity(); mSlideLayout.removeAllViews(); for (FunqLayer layer:mLayers) { if (layer!=null) { View v=layer.init_internal(context, mSlideLayout); // constructs the child layer, suppose it an ImageView if ((v!=null) && (mIsMuteTouches)) { v.setEnabled(false); v.setClickable(false); // this should obviously let touches pass through but it doesnt :( } } } if (mIsMuteTouches) { // also do the same in the FrameLayout itself with no luck :( mSlideLayout.setEnabled(false); mSlideLayout.setClickable(false); } } 
+7
source share
1 answer

Yes, obviouly I was missing onInterceptTouchEvent, overriding this to framelayout and returning true does the above redundancy:

  FrameLayout slideLayout=new FrameLayout(getActivity()){ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (mIsMuteTouches) return true; return super.onInterceptTouchEvent(ev); } }; 
+7
source

All Articles