horizontalscrollview如何同步两个HorizontalScrollView滚动效果

horizontalscrollview  时间:2021-06-20  阅读:()

HorizontalScrollView初始如何滚动到某一值?

经过我的实验,一下代码可以完美解决问题。

: new Handler().postDelayed((new Runnable() { @Override public void run() { sv_price.scrollTo(((RadioButton)rg_price.getChildAt(housePriceIndex)).getLeft()-100,0); } }),5);其中 ((RadioButton)rg_price.getChildAt(housePriceIndex)).getLeft()-100是我想把HorizontalScrollView sv_price滚动到的最终位置。

最后的一个5是延迟的时间。

正如9楼所说,我刚开始用的 handler.post 果断无效!这个好用!!

如果ListView中嵌套HorizontalScrollView怎么解决滑动错乱

最近在开发中遇到HorizontalScrollView嵌套ScrollView导致滑动卡的情况,急横向水平滑动的View和垂直水平滑动的View,都在接收处理滑动时间,但是这种情况下触摸事件就会发生冲突。

导致滑动非常卡,甚至出现程序停止响应。

这种情况下我们需要重写view。

下面是两个简单的例子,重写水平滑动View只接收水平方向上滑动的事件。

我们使用手势GestureDetector来作区分。

<em>import android.content.Context; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; import android.view.View; import android.widget.HorizontalScrollView; public class CustomHScrollView extends HorizontalScrollView{ private GestureDetector mGestureDetector; private View.OnTouchListener mGestureListener; private static final String TAG = "CustomHScrollView"; /** * @function CustomHScrollView constructor * @param context Interface to global information about an application environment. * */ public CustomHScrollView(Context context) { super(context); // TODO Auto-generated constructor stub mGestureDetector = new GestureDetector(new HScrollDetector()); setFadingEdgeLength(0); } /** * @function CustomHScrollView constructor * @param context Interface to global information about an application environment. * @param attrs A collection of attributes, as found associated with a tag in an XML document. */ public CustomHScrollView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub mGestureDetector = new GestureDetector(new HScrollDetector()); setFadingEdgeLength(0); } /** * @function CustomHScrollView constructor * @param context Interface to global information about an application environment. * @param attrs A collection of attributes, as found associated with a tag in an XML document. * @param defStyle style of view */ public CustomHScrollView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub mGestureDetector = new GestureDetector(new HScrollDetector()); setFadingEdgeLength(0); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev); } // Return false if we're scrolling in the y direction class HScrollDetector extends SimpleOnGestureListener { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if(Math.abs(distanceX) > Math.abs(distanceY)) { return true; } return false; } } } </em>

如何同步两个HorizontalScrollView滚动效果

可以尝试使用 GestureDetector, 我仅仅是理论上的描述,暂时没有环境可以运行。

假设是 scrollView1 带动 scrollView2。

在 scrollView1.setOnTouchListener() 里的事件传给 detector: detector.onTouchEvent( event ); 之后在 detectorListener 里: public boolean onScroll( MotionEvent e1, MotionEvent e2, float distanceX, float distanceY ) { int disX = ( int ) distanceX; scrollView2.scrollBy( disX, 0 ); return true; } 没有验证过,但我觉得八九不离十。

新版本Apache HTTP Server 2.4.51发布更新(有安全漏洞建议升级)

今天中午的时候看到群里网友在讨论新版本的Apache HTTP Server 2.4.51发布且建议更新升级,如果有服务器在使用较早版本的话可能需要升级安全,这次的版本中涉及到安全漏洞的问题。Apache HTTP 中2.4.50的修复补丁CVE-2021-41773 修复不完整,导致新的漏洞CVE-2021-42013。攻击者可以使用由类似别名的指令配置将URL映射到目录外的文件的遍历攻击。这里...

Linode 18周年庆典活动 不断改进产品结构和体验

今天早上相比很多网友和一样收到来自Linode的庆祝18周年的邮件信息。和往年一样,他们会回顾在过去一年中的成绩,以及在未来准备改进的地方。虽然目前Linode商家没有提供以前JP1优化线路的机房,但是人家一直跟随自己的脚步在走,确实在云服务器市场上有自己的立足之地。我们看看过去一年中Linode的成就:第一、承诺投入 100,000 美元来帮助具有社会意识的非营利组织,促进有价值的革新。第二、发...

Friendhosting四五折促销,VPS半年付7.5欧元起

Friendhosting发布了针对“系统管理日”(每年7月的最后一个星期五)的优惠活动,针对VPS主机提供55%的优惠(相当于四五折),支持1-6个月付款使用,首付折扣非永久,优惠后最低套餐首半年7.18欧元起。这是一家保加利亚主机商,成立于2009年4月,商家提供VDS和独立服务器租用等,数据中心目前可选美国洛杉矶、保加利亚、乌克兰、荷兰、拉脱维亚、捷克和波兰等8个地区机房。下面以最低套餐为例...

horizontalscrollview为你推荐
windowsmediawindows media player 是什么啊素数算法(c语言)求快速算素数的方法。各大网站有没有很好玩的网站啊pat是什么格式怎么将自己做的PS图片保存为PAT格式?刷ip流量如何刷自己网站的IP流量上行宽带上行宽带和下行宽带什么意思yui3yui 3 月9日 出的专辑的情报ocr软件下载哪个图片转文字软件比较好用?网页背景音乐代码网页背景音乐的源码一般在哪?asp论坛源码ASP论坛源代码为什么上传到ASP空间后打不开
linuxvps 踢楼 directspace siteground 美国php空间 ca4249 91vps 100mbps 搜索引擎提交入口 支持外链的相册 网站在线扫描 备案空间 114dns 可外链的相册 江苏双线 镇江高防服务器 中美互联网论坛 月付空间 时间同步服务器 火山互联 更多