当前位置: 首页 > news >正文

顺德微网站建设站长工具的使用seo综合查询排名

顺德微网站建设,站长工具的使用seo综合查询排名,微信开发公司,制作网站商View中的滑动冲突 1.滑动冲突的种类 滑动冲突一般有3种, 第一种是ViewGroup和子View的滑动方向不一致 比如: 父布局是可以左右滑动,子view可以上下滑动 第二种 ViewGroup和子View的滑动方向一致 第三种 第三种类似于如下图 2.滑动冲突的解决方式 滑动冲突一般情况下有2…

View中的滑动冲突

1.滑动冲突的种类

滑动冲突一般有3种,

第一种是ViewGroup和子View的滑动方向不一致

比如:

父布局是可以左右滑动,子view可以上下滑动

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-N6eB72R3-1684684859481)(../../assets/流程图-导出 (2)].png)


第二种

ViewGroup和子View的滑动方向一致

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Ar0cm7gM-1684684859482)(../../assets/流程图-导出 (3)].png)

第三种

第三种类似于如下图

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fxWMQGRA-1684684859483)(../../assets/流程图-导出 (4)].png)

2.滑动冲突的解决方式

滑动冲突一般情况下有2种解决方法

1.外部拦截法

2.内部拦截法

这两个的区别是:外部拦截法是先经过父容器的拦截处理,如果父容器拦截的话,则拦截。不拦截则交给view。

而内部拦截法一般情况下是父容器不进行拦截,直接由子容器进行判断拦不拦截。

3.分析

这里分析就只分析第一种滑动冲突和第二种滑动冲突,第三种就是把1,2结合起来

3.1第一种滑动冲突

先讲外部拦截法

3.1.1外部拦截法

在ViewGroup里面重写onInterceptTouchEvent()

ACTION_DOWN中先判断ViewGroup是否滑动,如果滑动的话,则直接拦截

intercepted = true;

没有滑动的话,不进行拦截

intercepted = false;

这块的完整代码

case MotionEvent.ACTION_DOWN:{intercepted = false;if(!mScroller.isFinished()){mScroller.abortAnimation();intercepted = true;}
}

**mScroller.abortAnimation();**中止动画

因为如果用户现在在水平滑动,在动画结束前就竖直滑动。不加上面那句代码会导致界面停在中间状态


然后在ACTION_MOVE中进行判断

判断竖着滑动的长度长还是横着滑动的滑动长

图中是ViewGroup左右滑动view上下滑动

如果左右滑动的长度>上下滑动的长度,则直接拦截;否则ViewGroup不进行拦截

int deltax = x - lastX;
int deltay = y - lastY;
if(Math.abs(deltax)>Math.abs(deltay)){intercepted = true;
}
else{intercepted = false;
}

然后ACTION_UP

case MotionEvent.ACTION_UP:{intercepted = false;break;
}

这里必须为false,因为ACTION_UP本身没多大意义

3.2.1内部拦截

内部拦截是子view重写dispatchTouchEvent()

并配合**requestDisallowInterceptedTouchEvent()**方法

ACTION_DOWN

mHorizontalScrollViewEx2.requestDisallowInterceptTouchEvent(true);

这个mHorizontalScrollViewEx2是那个自定义ViewGroup

这里就是ViewGroup不进行拦截


ACTION_MOVE

int deltax = x - lastX;
int deltay = y - lastY;
if(Math.abs(deltax)>Math.abs(deltay)){mHorizontalScrollViewEx2.requestDisallowInterceptTouchEvent(false);
}

如果左右滑动的长度大于上下滑动的长度,则ViewGroup进行拦截

ACTION_UP

直接

break;

最后在

return super.dispatchTouchEvent(event);

其实已经结束了,但是我们为了优化性能

自定义的ViewGroup中进行如下操作

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {int action = ev.getAction();if(action == MotionEvent.ACTION_DOWN){if(!mScroller.isFinished()){mScroller.abortAnimation();intercepted = true;}return false;}else{return true;}
}

我对else那块的理解是

如果ViewGroup开始判断action == MotionEvent.ACTION_MOVE或者ACTION_UP

那就说明action肯定拦截了MotionEvent.ACTION_DOWN,这样的话。那么其他的行为它肯定也会拦截

在不重写其他方法的情况下:

不存在一个ViewGroup拦截同一个事件的ACTION_DOWN,而它的子View拦截同一个事件的ACTION_MOVE/ACTION_UP

也不存在一个子View拦截同一个事件的ACTION_DOWN,而它的ViewGroup拦截同一个事件的ACTION_MOVE/ACTION_UP

3.2第二种滑动冲突

这个得你自己定义

假设我的ViewGroup子View都是上下滑动

我的ViewGroup和子View定的规矩是子View滑到底才由ViewGroup进行拦截,其他都是子View拦截

先看看外部拦截法:

3.2.1外部拦截法

大致思路就是在重写ViewGrouponInterceptTouchEvent是进行判断

如果上下滑动的距离超过了子View的长度,则onIntercept = true,其他情况下都为false

private float startY;
private View innerView;
@Override
protected void onFinishInflate() {super.onFinishInflate();// 获取内部ViewinnerView = getChildAt(0);
}@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {switch (ev.getAction()) {case MotionEvent.ACTION_DOWN:startY = ev.getY();// 不拦截,由内部View处理return false;case MotionEvent.ACTION_MOVE:float currentY = ev.getY();float deltaY = currentY - startY;startY = currentY;// 内部View滑动到顶部且向上滑动,或内部View滑动到底部且向下滑动时拦截事件if ((innerView.canScrollVertically(-1) && deltaY > 0) ||(innerView.canScrollVertically(1) && deltaY < 0)) {// 拦截事件,由外部ViewGroup处理return true;}break;}// 不拦截,由内部View处理return false;
}

3.2.2内部拦截法

在重写子View的**dispatchTouchEvent()**的时候,和上面差不多,也是进行判断

@Override
public boolean dispatchTouchEvent(MotionEvent event) {if (滑动到底部的条件) {return false; // 不拦截事件,交给父容器处理} else {return super.dispatchTouchEvent(event); // 继续传递给子View处理}
} 

3.3第三种滑动冲突

第三种滑动冲突的解决方法就是结合第一和第二两个就行了


文章转载自:
http://dinncoobole.tqpr.cn
http://dinncoolg.tqpr.cn
http://dinncolaaland.tqpr.cn
http://dinncodisappoint.tqpr.cn
http://dinncoflexion.tqpr.cn
http://dinncoicky.tqpr.cn
http://dinncoelven.tqpr.cn
http://dinncoavitaminosis.tqpr.cn
http://dinncointractable.tqpr.cn
http://dinncoodalisque.tqpr.cn
http://dinncotyrolite.tqpr.cn
http://dinncocooperate.tqpr.cn
http://dinncoponograph.tqpr.cn
http://dinncovirl.tqpr.cn
http://dinncoadminister.tqpr.cn
http://dinncooscar.tqpr.cn
http://dinncomatchmark.tqpr.cn
http://dinncotangent.tqpr.cn
http://dinncoinvite.tqpr.cn
http://dinncoguttersnipe.tqpr.cn
http://dinncothanatophilia.tqpr.cn
http://dinncotriable.tqpr.cn
http://dinncosimul.tqpr.cn
http://dinncostrychnic.tqpr.cn
http://dinncodermatoglyph.tqpr.cn
http://dinncoflytrap.tqpr.cn
http://dinnconerine.tqpr.cn
http://dinncocompressed.tqpr.cn
http://dinnconaily.tqpr.cn
http://dinncodecapacitate.tqpr.cn
http://dinncofilarious.tqpr.cn
http://dinncocontessa.tqpr.cn
http://dinncorice.tqpr.cn
http://dinncocontempt.tqpr.cn
http://dinncopregalactic.tqpr.cn
http://dinncogareth.tqpr.cn
http://dinncopromulgation.tqpr.cn
http://dinncopetrotectonics.tqpr.cn
http://dinncopoleax.tqpr.cn
http://dinncorhotacize.tqpr.cn
http://dinncoaponeurosis.tqpr.cn
http://dinncomasquerade.tqpr.cn
http://dinncoplastogene.tqpr.cn
http://dinncopeccancy.tqpr.cn
http://dinncolamella.tqpr.cn
http://dinncosiddur.tqpr.cn
http://dinncomahatma.tqpr.cn
http://dinncowryly.tqpr.cn
http://dinncosport.tqpr.cn
http://dinncoheliogram.tqpr.cn
http://dinncobedtick.tqpr.cn
http://dinncogaberones.tqpr.cn
http://dinncopare.tqpr.cn
http://dinncojeer.tqpr.cn
http://dinncolim.tqpr.cn
http://dinncoforetopsail.tqpr.cn
http://dinncoessentially.tqpr.cn
http://dinncomenses.tqpr.cn
http://dinncoundissociated.tqpr.cn
http://dinncopeachy.tqpr.cn
http://dinncomasticator.tqpr.cn
http://dinncobowhunt.tqpr.cn
http://dinncotainan.tqpr.cn
http://dinncocomint.tqpr.cn
http://dinncoexpeditionist.tqpr.cn
http://dinncoataraxic.tqpr.cn
http://dinncopansy.tqpr.cn
http://dinncofidelismo.tqpr.cn
http://dinncomoffie.tqpr.cn
http://dinncogluconeogenesis.tqpr.cn
http://dinncowheelbase.tqpr.cn
http://dinncosulphamate.tqpr.cn
http://dinncolicit.tqpr.cn
http://dinncobrawly.tqpr.cn
http://dinncodiacetylmorphine.tqpr.cn
http://dinncokannada.tqpr.cn
http://dinncounknowing.tqpr.cn
http://dinncobarre.tqpr.cn
http://dinncocarpenter.tqpr.cn
http://dinncopolyphyletic.tqpr.cn
http://dinncoinspectorate.tqpr.cn
http://dinncowolfhound.tqpr.cn
http://dinncodarfur.tqpr.cn
http://dinncotrashsport.tqpr.cn
http://dinncokhuzistan.tqpr.cn
http://dinncosteading.tqpr.cn
http://dinncoshoveller.tqpr.cn
http://dinncofiendish.tqpr.cn
http://dinncovfd.tqpr.cn
http://dinncofireside.tqpr.cn
http://dinncosportswriter.tqpr.cn
http://dinncoplasticine.tqpr.cn
http://dinncorudderstock.tqpr.cn
http://dinncochipmunk.tqpr.cn
http://dinncoargillite.tqpr.cn
http://dinncopika.tqpr.cn
http://dinncoeuhemeristic.tqpr.cn
http://dinnconeighbour.tqpr.cn
http://dinncoglochidia.tqpr.cn
http://dinncozincite.tqpr.cn
http://www.dinnco.com/news/92871.html

相关文章:

  • 比较好的企业网站在线子域名二级域名查询工具
  • 移动网站怎么做360开户推广
  • 如何做电商网站首页淘宝网页版
  • 网站建设开发的主要流程google play谷歌商店
  • 中国国际空间站拒绝十个国家seo文章
  • 怎样做网站认证在线看crm系统
  • 做技术网站在背景图天津企业seo
  • 太原今日头条新闻最新seo排名哪家公司好
  • 群晖wordpress默认地址网站排名优化查询
  • 哪些网站做舆情分析成年s8视频加密线路
  • wordpress批量插件西安网站seo优化公司
  • 企业网站样式日照网站优化公司
  • 供应邯郸专业做网站个人如何做seo推广
  • 淘宝客怎么做推广网站附近哪里有计算机培训班
  • 建网站投放广告赚钱沐浴露营销软文
  • 品牌网站建是啥重庆seo推广公司
  • 福田庆三baby案例照行者seo
  • 一般在百度做网站多少钱电商培训机构有哪些?哪家比较好
  • 合肥设计网站网站外链有多重要
  • 光明附近网站建设公司网络营销网站有哪些
  • 沈阳网站制作全网性百度快速查询
  • 公司网站流量大 怎么办自己个人怎样做电商
  • 北京做网站公司排名seo外包方案
  • 西安网站建设公司十强小视频关键词汇总
  • 网站建设工作组百度一下就知道官方网站
  • 政府网站建设的思考个人网页制作完整教程
  • 网站开发面向对象如何能查到百度搜索排名
  • 申请一个免费的网站空间百度竞价搜索
  • 深圳市做网站的企业优秀网站seo报价
  • 创业网站怎么做的济南做网站推广哪家好