我找不到使这个工作的方法。
我的应用程序有2个FrameLayouts,每个都有许多子视图(为简单起见,假设是ImageViews),一个叠在另一个上面。
我的问题是,我需要在顶部的FrameLayout和其所有子元素中让触摸事件通过它们,并达到底部的FrameLayout(及其子元素)。就像应用于顶部framelayout的所有imageviews的HTML中的pointer-events:none一样。
我尝试在FrameLayout及其子项上同时使用setClickable(false)和setEnabled(false),但如果我点击禁用的子项(例如,一个ImageView),触摸将无法到达底层ImageView(即底部FrameLayout的子项)
以下代码是我最好的尝试来禁用FrameLayout及其子元素(mSlideLayout是父FrameLayout,layer是每个imageview的子项)。我错过了什么吗??
/** 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's 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);
}
}