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

Virmach$7.2/年,新款月抛vps上线,$3.23/半年,/1核640M内存/10 GB存储/ 1Gbps/1T流量

Virmach自上次推出了短租30天的VPS后,也就是月抛型vps,到期不能续费,直接终止服务。此次又推出为期6个月的月抛VPS,可选圣何塞和水牛城机房,适合短期有需求的用户,有兴趣的可以关注一下。VirMach是一家创办于2014年的美国商家,支持支付宝、PayPal等方式,是一家主营廉价便宜VPS服务器的品牌,隶属于Virtual Machine Solutions LLC旗下!在廉价便宜美国...

数脉科技香港物理机 E3 16G 10M 华为线路165元 阿里云线路 188元 Cera线路 157元

2021年9月中秋特惠优惠促销来源:数脉科技 编辑:数脉科技编辑部 发布时间:2021-09-11 03:31尊敬的新老客户:9月优惠促销信息如下,10Mbps、 30Mbps、 50Mbps、100Mbps香港优质或BGPN2、阿里云线路、华为云线路,满足多种项目需求!支持测试。全部线路首月五折起。数脉官网 https://my.shuhost.com/香港特价数脉阿里云华为云 10MbpsCN...

火数云 55元/月BGP限时三折,独立服务器及站群限时8折,新乡、安徽、香港、美国

火数云怎么样?火数云主要提供数据中心基础服务、互联网业务解决方案,及专属服务器租用、云服务器、专属服务器托管、带宽租用等产品和服务。火数云提供洛阳、新乡、安徽、香港、美国等地骨干级机房优质资源,包括BGP国际多线网络,CN2点对点直连带宽以及国际顶尖品牌硬件。专注为个人开发者用户,中小型,大型企业用户提供一站式核心网络云端服务部署,促使用户云端部署化简为零,轻松快捷运用云计算!多年云计算领域服务经...

horizontalscrollview为你推荐
win7中文语言包win7专业版怎么安装中文语言包implement_dynamic(VC++)DECLARE_DYNAMIC(CDrawToolDlg)这个是什么意思?pat是什么格式pat是什么格式的文件啊shoujiao求【叫兽】的简介wow服务器状态我电脑上的魔兽服务器状态很好.但是还是玩不起来.请问可以玩了不?databasenamefoxpro中的的命令格式yui3YUI最详细的资料怎么查微信注册时间怎么查对方的微信号什么时候注册的cc防火墙服务器里安全狗里的WEB防火墙是什么意思distinct是什么意思SQL数据库DISTINCT是什么意思
服务器租用托管 域名服务器的作用 查询ip地址 快速域名备案 新网域名解析 荷兰服务器 virpus 哈喽图床 天猫双十一秒杀 网站被封 华为网络硬盘 元旦促销 阿里云浏览器 qq云端 上海服务器 购买国外空间 服务器是干什么用的 帽子云排名 独立主机 杭州电信宽带优惠 更多