android – 制作前景视图点击

android – 制作前景视图点击,第1张

概述我找不到让这项工作的方法. 我的应用程序有2个FrameLayouts和许多子视图(为简单起见,假设ImageViews),一个堆叠在另一个上. 我的问题是,我需要TOP上的FrameLayout和所有它的孩子让触摸通过它们,到达底层的FrameLayout(及其子节点).像指针事件:HTML中没有应用于TOP framelayout的所有图像视图. 我已经在FrameLayout及其子节点上尝试 我找不到让这项工作的方法.

我的应用程序有2个FrameLayouts和许多子视图(为简单起见,假设ImageVIEws),一个堆叠在另一个上.

我的问题是,我需要top上的FrameLayout和所有它的孩子让触摸通过它们,到达底层的FrameLayout(及其子节点).像指针事件:HTML中没有应用于top framelayout的所有图像视图.

我已经在FrameLayout及其子节点上尝试了setClickable(false)和setEnabled(false),但是如果我单击一个禁用的子节点(例如ImageVIEw),触摸将无法到达底层的ImageVIEw(即底层的子节点)的FrameLayout)

以下代码是我最好的尝试禁用FrameLayout及其子代(mSlIDeLayout是父FrameLayout,图层是每个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);    }}
解决方法 是的,显然我缺少onIntercepttouchEvent,在framelayout中覆盖它并返回true使上述例程变得多余:
FrameLayout slIDeLayout=new FrameLayout(getActivity()){        @OverrIDe        public boolean onIntercepttouchEvent(MotionEvent ev) {            if (mIsMutetouches) return true;            return super.onIntercepttouchEvent(ev);        }    };
总结

以上是内存溢出为你收集整理的android – 制作前景视图点击全部内容,希望文章能够帮你解决android – 制作前景视图点击所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1138466.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存