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; } 没有验证过,但我觉得八九不离十。

云如故枣庄高防(49元)大内存2H2G49元8H8G109元

云如故是一家成立于2018年的国内企业IDC服务商,由山东云如故网络科技有限公司运营,IDC ICP ISP CDN VPN IRCS等证件齐全!合法运营销售,主要从事自营高防独立服务器、物理机、VPS、云服务器,虚拟主机等产品销售,适合高防稳定等需求的用户,可用于建站、游戏、商城、steam、APP、小程序、软件、资料存储等等各种个人及企业级用途。机房可封UDP 海外 支持策略定制 双层硬件(傲...

UCloud:美国云服务器,洛杉矶节点大促,低至7元起/1个月

ucloud美国云服务器怎么样?ucloud是国内知名云计算品牌服务商家,目前推出全球多地机房的海外云服务器。UCloud主打的优势是海外多机房,目前正在进行的2021全球大促活动参与促销的云服务器机房就多达18个。UCloud新一代旗舰产品快杰云服务器已上线洛杉矶节点,覆盖北美和亚太地区,火热促销中, 首月低至7元,轻松体验具备优秀性能与极高性价比的快杰云服务器。点击进入:ucloud美国洛杉矶...

青云互联:洛杉矶CN2弹性云限时七折,Cera机房三网CN2gia回程,13.3元/月起

青云互联怎么样?青云互联是一家成立于2020年6月份的主机服务商,致力于为用户提供高性价比稳定快速的主机托管服务,目前提供有美国免费主机、香港主机、香港服务器、美国云服务器,让您的网站高速、稳定运行。目前,美国洛杉矶cn2弹性云限时七折,美国cera机房三网CN2gia回程 13.3元/月起,可选Windows/可自定义配置。点击进入:青云互联官网青云互联优惠码:七折优惠码:dVRKp2tP (续...

horizontalscrollview为你推荐
郭列90后三无人物,如何创业?如何去实现人生价值?国家法规数据库在哪里可以找到比较全面的法律法规更新的信息?云输入法QQ云输入法怎样进行中英文切换?腾讯合作伙伴大会如何成为腾讯渠道合作伙伴?erp系统教程ERP系统怎样操作,有教学视频吗?怎么查微信注册时间怎么查看自己的微信号用了多久怎么查微信注册时间怎么知道微信上次登录时间在线沟通网络沟通的问题有哪些泛微协同办公系统谁能告诉我泛微OA,协同性是体现在哪几个方面的?泛微有哪些优势??particular教程有没有制作花瓣飘落的AE教程
成都虚拟空间 网站空间免备案 长沙域名注册公司 edgecast plesk 国外php主机 BWH 青果网 搜狗12306抢票助手 太原联通测速平台 qingyun 165邮箱 ftp教程 什么是刀片服务器 重庆双线服务器托管 hkt 韩国代理ip 万网空间 江苏徐州移动 免费赚q币 更多