Android 点击View外部消失
来源:互联网 发布:电音大神 知乎 编辑:程序博客网 时间:2024/05/20 11:46
public void setOnTouchOutsideViewListener(View view, OnTouchOutsideViewListener onTouchOutsideViewListener) { mTouchOutsideView = view; mOnTouchOutsideViewListener = onTouchOutsideViewListener;}public OnTouchOutsideViewListener getOnTouchOutsideViewListener() { return mOnTouchOutsideViewListener;}@Overridepublic boolean dispatchTouchEvent(final MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { // Notify touch outside listener if user tapped outside a given view if (mOnTouchOutsideViewListener != null && mTouchOutsideView != null && mTouchOutsideView.getVisibility() == View.VISIBLE) { Rect viewRect = new Rect(); mTouchOutsideView.getGlobalVisibleRect(viewRect); if (!viewRect.contains((int) ev.getRawX(), (int) ev.getRawY())) { mOnTouchOutsideViewListener.onTouchOutside(mTouchOutsideView, ev); } } } return super.dispatchTouchEvent(ev);}/** * Interface definition for a callback to be invoked when a touch event has occurred outside a formerly specified * view. See {@link #setOnTouchOutsideViewListener(View, OnTouchOutsideViewListener).} */public interface OnTouchOutsideViewListener { /** * Called when a touch event has occurred outside a given view. * * @param view The view that has not been touched. * @param event The MotionEvent object containing full information about the event. */ public void onTouchOutside(View view, MotionEvent event);}
0 0
- Android 点击View外部消失
- Android Popupwindow 点击外部消失的实现
- android popuwindow点击外部窗口不消失
- android 5.0 popuwindow 点击外部不消失
- 点击PopupWindow外部消失
- popwindow 点击外部消失
- 解决android中点击对话框外部,对话框消失的问题
- android PopupWindow点击外部和返回键消失
- 解决android中点击对话框外部,对话框消失的问题
- Android popupWindow 点击外部消失,点击外部其他控件触发其他事件
- 点击外部时本身消失
- Dialog点击外部自动消失
- 点击PopupWindow 外部区域消失
- PopupWindow点击外部区域消失
- Activity对话框,点击外部不消失
- PopupWindow点击外部区域消失(二)
- PopupWindow点击外部区域消失(三)
- popupwindow的基本应用,点击外部消失
- ReactNative之ListView学习总结(二)带有section的demo
- OpenGL(十) 手机不可用特性 ComputeShader GeometryShader ...
- Android 原生控件 2 Switch 和 TogglBUtton
- POJ-2373-Dividing the Path
- 修改SVN已提交项目的消息日志
- Android 点击View外部消失
- android 获取app使用的CPU
- 关于PHP内部编码与mysql字符差异问题的研究
- 收藏的博客地址
- snpKit 关于自动布局
- Mysql修改数据类型
- AOP 自定义日志
- 算法学习之一:堆排序
- 利用XDroidMvp快速实现mvp设计模式(一)