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

香港最便宜的vps要多少钱?最便宜的香港vps能用吗?

香港最便宜的vps要多少钱?最便宜的香港vps能用吗?香港vps无需备案,整体性能好,而且租用价格便宜,使用灵活,因为备受站长喜爱。无论是个人还是企业建站,都比较倾向于选择香港VPS。最便宜的香港vps能用吗?正因为有着诸多租用优势,香港VPS在业内颇受欢迎,租用需求量也在日益攀升。那么,对于新手用户来说,香港最便宜的vps租用有四大要点是务必要注意的,还有易探云香港vps租用最便宜的月付仅18元...

GigsGigsCloud(年付26美元)国际线路美国VPS主机

已经有一段时间没有听到Gigsgigscloud服务商的信息,这不今天看到商家有新增一款国际版线路的美国VPS主机,年付也是比较便宜的只需要26美元。线路上是接入Cogentco、NTT、AN2YIX以及其他亚洲Peering。这款方案的VPS主机默认的配置是1Gbps带宽,比较神奇的需要等待手工人工开通激活,不是立即开通的。我们看看这款服务器在哪里选择看到套餐。内存CPUSSD流量价格购买地址1...

UCloud云服务器香港临时补货,(Intel)CN2 GIA优化线路,上车绝佳时机

至今为止介绍了很多UCLOUD云服务器的促销活动,UCLOUD业者以前看不到我们的个人用户,即使有促销活动,续费也很少。现在新用户的折扣力很大,包括旧用户在内也有一部分折扣。结果,我们的用户是他们的生存动力。没有共享他们的信息的理由是比较受欢迎的香港云服务器CN2GIA线路产品缺货。这不是刚才看到邮件注意和刘先生的通知,而是补充UCLOUD香港云服务器、INTELCPU配置的服务器。如果我们需要他...

horizontalscrollview为你推荐
sql四舍五入sql怎样四舍五入保留小数点后1位gas是什么意思petrol和gas的区别动画分镜头脚本动画分镜头台本的作用?gbk内码高考姓名gbk内码查询怎么查微信注册时间怎么查一个微信公众号的注册时间,发了多少条内容怎么查微信注册时间怎么知道微信上次登录时间在线沟通网络沟通的问题有哪些backupexec怎样在vmware vcenter上安装backup exec agent for windowsidataparameterweighting parameter是什么意思微盟价格微盟怎么收费?
大庆服务器租用 阿里云邮箱登陆首页 优惠码 sockscap 174.127.195.202 服务器cpu性能排行 绍兴高防 浙江独立 国外在线代理 hkg 美国在线代理服务器 中国电信宽带测速网 免费cdn Updog vul 阿里云免费邮箱 免费个人主页 江苏徐州移动 杭州电信 腾讯云平台 更多