onTouchEvent 何时调用 ACTION_OUTSIDE

WindowManager Flag对View触摸事件的影响 Window Flag对View的影响 阅读详情

参见Dialog的点击Dialog外关闭Dialog

要想获取该事件, 必须要求当前Window的包含FLAG_WATCH_OUTSIDE_TOUCH

public class DialogOutSide extends Dialog{
    public DialogOutSide(Context context) {
        super(context);
 init();
 }

    protected DialogOutSide(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
 init();
 } 

    public DialogOutSide(Context context, int themeResId) {
        super(context, themeResId);
 init();
 }

    @Override
 public boolean onTouchEvent(MotionEvent event) {
 if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
            Log.i("yyy","outside");
 return true;
 }


 return super.onTouchEvent(event);
 }


    private void init(){
        setContentView(R.layout.dialog_outside);
 //清空
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
 //设置 这种模式当触发outside touch时响应
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
 }
}

Android自定义控件进阶13-MotionEvent详解 Android MotionEvent 详解,之前用了两篇文章 事件分发机制原理 和 事件分发机制详解 来讲解事件分发,而作为事件分发主角之一的 MotionEvent 并没有过多的说明,本文就带大家了解 MotionEvent 的相关内容,简要介绍触摸事件,主要包括 单点触控、多点触控、鼠标事件 以及 getAction() 和 getActionMasked() 的区别。 Android 将所有的输入事件都放在了 MotionEvent 中,随着安卓的不断发展壮大,MotionEvent 也开始变得越来 阅读详情

相关推荐

自定义PhotoView事件分发项目实战(一):MotionEvent与多触点

手指。

2401_84149882的博客 762

Android Touch 事件----MotionEvent介绍

MotionEvent 介绍单点触控ACTION_CANCEL和ACTION_OUTSIDE出现场景常用函数多点触控多点下的action表达方式actionIndex 、pointerIndex和pointerId的关系历史数据批处理常用方法 单点触控 常见事件 事件 动作 ACTION_DOWN=0 手指 初次接触 到屏幕 ACTION_UP=1 手指 离开屏幕 时触发 ...

weixin_43236827的博客 1859

javaFx + SpringBoot 启动时报错:No auto configuration classes found in META-INF/spring.factories 解决方法

javaFx+SpringBoot+(de.roskenet:springboot-javafx-support:2.1.6)开发。 直接在idea中运行正常,但打包成jar,之后使用java -jar xxx.jar启动报错,发现日志中有: java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. 以及 at de.felixroske.jfxsuppo

long117long的专栏 4611

Android多点触控

Android多点触控 1.单点触控重点属性 事件类型 含义 ACTION_DOWN 手指 初次接触到屏幕 时触发。 ACTION_MOVE 手指 在屏幕上滑动 时触发,会多次触发。 ACTION_UP 手指 离开屏幕 时触发。 ACTION_CANCEL 事件 被上层拦截 时触发。 ACTION_OUTSIDE 手指...

caoyangyang123的博客 674

UE4 - 河流流体插件Fluid Flux

Fluid Flux可以模拟一定区域内的流体效果,由于使用顶视图所Capture的Heightfield信息,所以只支持室外开阔场景,不支持洞穴等室内场景;

GT的虚幻引擎文档 6666

python电子学会三级的零碎笔记

‌示例‌:如果s = ['a', 'b', 'c'],则' '.join(s)+'\n'的结果是'a b c\n',写入文件时所有元素会在一行内显示,每个元素之间用空格分隔,末尾有一个换行符。(2) '\n'.join(s)‌:如果s = ['a', 'b', 'c'],则'\n'.join(s)的结果是'a\nb\nc',写入文件时每个元素会占据文件的一行。(1) ' '.join(s)+'\n'‌:这种方式首先将列表s中的每个元素通过空格连接成一个字符串,然后在字符串末尾添加一个换行符\n。

xzal12的博客 690

Android自定义控件从零开始-第三篇 深入解析View的事件和常用方法

Android自定义控件从零开始-第一篇 View的绘制流程 中我们简单了解了View绘制最基础的一些流程和API。 Android自定义控件从零开始-第二篇 自定义TooBar、跑马灯 中我们根据最基础的绘制流程完成了两个简单的控件。 今天我们将深入解析View的事件和常用方法,学会了这些后,至少一些日常的自定义控件对你而言将不再是难点。用户交互是除了页面显示之外的主要功能,比如用户点击一个按钮,滑动一个列表,左右切换页面,双指放大页面等操作都是对用户触摸事件的处理,实际中由于页面的复杂性,还可能造成事件

Web311的博客 963

汇川伺服Modbus-RTU通讯实战:从帧结构解析到西门子PLC配置

本文详细解析了汇川伺服与西门子PLC通过Modbus-RTU协议进行通讯的实战步骤,包括帧结构解析、硬件连接、参数设置及PLC程序配置。通过具体案例和常见问题排查指南,帮助工程师快速掌握工业自动化中的通讯技术,提升设备调试效率。

weixin_33670713的博客 453

Touch事件传递流程、事件分发中的onTouch 和onTouchEvent 有什么区别,又该如何使用?

Touch事件传递流程、事件分发中的onTouch 和onTouchEvent 有什么区别,又该如何使用?

大白 2945

用ESP32-S3和USB摄像头DIY一个无线图传监控(附完整代码和接线图)

本文详细介绍了如何利用ESP32-S3开发板和USB摄像头打造一套高性价比的无线图传监控系统。从硬件选型、接线图到代码实现,提供了完整的DIY方案,特别适合家庭监控、宠物看护等场景。通过优化WiFi传输和双核任务分配,实现了稳定的视频流传输,整套方案成本控制在200元以内。

weixin_33701251的博客 519

基于libVLC的视频播放器之四:直接使用libVLC

一.效果 播放本地文件 播放网络url:rtsp://3.84.6.190/vod/mp4:BigBuckBunny_115k.mov 二.实现 既然有VLC-Qt,为什么还要直接调用libVLC呢,因为直接调用会加深对整个播放流程的理解,方便后面修改VLC-Qt源码。 注意事项: 1.编译报错:error C2065: “libvlc_media_read_cb”: 未声明的标识符。修改如下: 2.libvlc_new(0, nullptr)返回null 将plugins

草上爬的博客 5048

Android 中的 onInterceptTouchEvent() 和 onTouchEvent()

onInterceptTouchEvent() public boolean onInterceptTouchEvent (MotionEvent ev) onInterceptTouchEvent()是ViewGroup的方法。他主要用于处理触摸事件并改变事件的传递方向。 参数 MotionEvent ev: 常见的动作常量: 内容 解释 publ

abbydong的博客 634

使用modelscope加载报错:ImportError: cannot import name ‘AutoTokenizer’ from ‘modelscope’...如何解决?| 提供多种解决方案

🏆本文收录于 《全栈Bug调优(实战版)》 专栏,该专栏专注于分享我在真实项目开发中遇到的各类疑难Bug及其深层成因,并系统提供高效、可复现的解决思路和实操方案。无论你是刚入行的新手开发者,还是拥有多年项目经验的资深工程师,本专栏都将为你提供一条系统化、高质量的问题排查与优化路径,助力你加速成长,攻克技术壁垒,迈向技术价值最大化与职业发展的更高峰🚀!

**My Coding Family** 1241

第16天 Android Touch事件学习 3 区分各种手势基础知识

这是事件学习的第三篇文章了,以下是之前的文章:       《Touch事件学习 1 点击事件》       《Touch事件学习 2 触发点击事件的地方》      之前分析点击事件从view.setOnClickListener源码一路查找,发现最终处理的地方是在onTouchEvent,但是仅仅获取到这些信息还是无法解释对于触屏事件的理解,还是会有很多疑惑,而且点击事件也没

Android 3437

我写了一个自动识别火车车厢位置的算法【lidar点云识别】

我写了一个自动识别火车车厢位置的算法【lidar点云识别】

qq_43212290的博客 797

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Andorid-onTouchEvent回调

安卓的触摸方法–回调 当用户触摸的时候自动调用的方法@Override 
public boolean onTouchEvent(MotionEvent event) {

 int action = event.getAction();

 switch (action) {
 case MotionEvent.ACTION_DOWN: {

Jerry’s Blog 574

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

タッチイベントをとりえする「onTouchEventとMotionEvent」

ActivityとViewのTouchEvent onTouchEventの呼び出し優先順位は上位のView>下位のView>Activityです。 クラスとメソッド 説明 Activity.onTouchEvent Viewで消費されなかった場合、呼び出される View.onTouchEvent 上位レ

不老的心 942

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Android事件分发机制浅析

文章目录前言一.MotionEvent 前言 事件分发机制在Android体系中是相当重要的,在自定义View的时候可能需要考虑事件分发机制的影响。之前也看过别人写的文章,但是总感觉容易忘记,这里就对Android事件分发机制做一下浅析。 一.MotionEvent MotionEvent是一个用于记录你接触屏幕后留下的一系列的事件。这些事件用的最多就是这几个ACTION_DOWN,ACTION_...

RQ997832的专栏 651

setOnTouchListener在小米手机中不走ACTION_UP而是走ACTION_CANCEL

单点触控: MotionEvent.ACTION_DOWN:手指初次接触到屏幕时触发。 MotionEvent.ACTION_MOVE:手指在屏幕上滑动时触发,会多次触发。 MotionEvent.ACTION_UP:手指离开屏幕时触发。 MotionEvent.ACTION_CANCEL:事件被上层拦截时触发。 MotionEvent.ACTION_OUTSIDE:手指...

weixin_30344995的博客 541

Android的Touch系统简介(一)

Android touch事件的相关概念

bigconvience的专栏 1万+

android dialog activity touch outside

BUG描述源地址:http://stackoverflow.com/questions/12102777/prevent-android-activity-dialog-from-closing-on-outside-touch BUG现象:   (1) UI界面弹出一个Dialog Activity;   (2) 点击该Dialog Activity外的Button(该Button属...

weixin_30402085的博客 446

View事件分发

是Android系统中一个非常重要的类,它代表了屏幕上发生的触摸事件。当用户在屏幕上触摸、滑动或者长按时,都会生成一个对象,这个对象包含了触摸动作的各种信息。

m0_60610120的博客 1050

Android6.0触摸事件分发机制解读

本篇博文是Android触摸事件分发机制系列博文的第一篇,带领大家从全局掌握Android触摸事件分发机制。特别声明的是,本源码解读是基于最新的Android6.0版本。为什么要解读触摸事件分发机制1.掌握View事件分发机制 2.为解决View滑动冲突提供理论支持 3.了解Android最新源码改动Touch触摸事件    在Android中Touch触摸事件主要包括点击(onClick)

Android研发专栏 1万+

note_45:手势检测

MotionEvent、onTouchEvent、GestureDetector 参考: onTouchevent() vs onTouch() 安卓自定义View进阶-MotionEvent详解 触摸事件【MotionEvent】简介 ACTION_CANCEL,ACTION_OUTSIDE 的触发条件与使用 事件处理之onTouchEvent()和onTouch()方法精炼详解 3.1.3 MotionEvent和TouchSlop 文章目录MotionEvent、onTouchEvent、Ges

Blog 2275

看看Android的触摸事件分发

同一个事件序列是指从手指接触屏幕到手指离开,整个事件序列都是以down事件开始,中间含还有数量不等的move事件,最终以up事件结束。

Jason_Lee155的博客 1383

Android中Dialog两种设置外部点击事件的方法

Android中Dialog实现两种设置外部点击事件的方法

时光一去不在的博客 3673
上一篇: selector 文件设置 state_checked 无效
下一篇: NestedScrollView嵌套RecyclerView时滑动不流畅
杨殿生
博客等级 码龄10年 11粉丝 77原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值