引用:http://mengsina.iteye.com/blog/1707464

http://fenglog.com/article.asp?id=449

Android ScrollView嵌套ScrollView滚动的问题解决办法 
原文地址:http://trivedihardik.wordpress.com/2011/09/19/scrollview-inside-scrollview-scrolling-problem/

搞技术的多少看的懂E文,也不翻译了。

While designing rich layouts you might need to use two scrollview in your app. 
Well ideally its not advised to use two scrollview in a view. So try to avoid it.

Why this problem occurs ? :

When you put two scrollview android just get confused which scroll view is touched. So sometimes it gets unable to deliver touch event.

But even if the requirement forces you to make such layouts. Try this…

Say case is somewhat like this….

    <ScrollViewandroid:id="@+id/parent_scroll"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="@color/black"android:cacheColorHint="#00000000"android:fadingEdge="none"android:overScrollMode="never"android:scrollbars="none"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:orientation="vertical"><ScrollViewandroid:id="@+id/child_scroll"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_toRightOf="@+id/TextView001"android:cacheColorHint="#00000000"android:fadingEdge="none"android:overScrollMode="never"android:scrollbars="none"><TextViewandroid:id="@+id/tv_detail"android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="15dp"android:textColor="@color/cbWhite"android:textSize="@dimen/cb_textSize_big"/></ScrollView></LinearLayout></ScrollView>

Step 1 : Provide unique id to both the scrollview. 
Step 2 : get reference of that two scrollview in your activity.

    ScrollView parentScroll = (ScrollView) findViewById(R.id.parent_scroll);ScrollView childScroll = (ScrollView) findViewById(R.id.child_scroll);

Step 3: Now set touch listeners for both.

        parentScroll.setOnTouchListener(new View.OnTouchListener() {public boolean onTouch(View v, MotionEvent event) {findViewById(R.id.child_scroll).getParent().requestDisallowInterceptTouchEvent(false);return false;}});childScroll.setOnTouchListener(new View.OnTouchListener() {public boolean onTouch(View v, MotionEvent event) {// Disallow the touch request for parent scroll on touch of child viewv.getParent().requestDisallowInterceptTouchEvent(true);return false;}});

Done …

转载于:https://www.cnblogs.com/niray/p/4600391.html

Android ScrollView嵌套ScrollView滚动的问题解决办法相关推荐

  1. [RN] React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法

    [RN] React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法 参考文章: (1)[RN] React Native 键盘管理 在Android TextI ...

  2. Android截屏SurfaceView黑屏问题解决办法

    Android截屏SurfaceView黑屏问题解决办法 参考文章: (1)Android截屏SurfaceView黑屏问题解决办法 (2)https://www.cnblogs.com/kongyf ...

  3. 在android中ScrollView嵌套ScrollView解决方案

    文章转载自:http://www.jb51.net/article/33054.htm 大家好,众所周知,android里两个相同方向的ScrollView是不能嵌套的,那要是有这样的需求怎么办,接下 ...

  4. [Android实例] [版主原创]ScrollView嵌套ScrollView

    大家好,众所周知,android 里两个相同方向的ScrollView是不能嵌套的,那要是有这样的需求怎么办?(这个需求一般都是不懂android的人提出来的) 难道就真的不能嵌套吗? 当然可以,只要 ...

  5. ScrollView嵌套ScrollView

    原博客地址: http://www.eoeandroid.com/thread-240709-1-1.html 大家好,众所周知,android 里两个相同方向的ScrollView是不能嵌套的,那要 ...

  6. Android Activity之间切换闪屏问题解决办法

    在实际开发中,界面切换除了在同一个页面上显示不同的UI,可以使用fragment进行实现,当fragment嵌套层级过多的 时候,可以使用activity切换实现类似的功能,实现方法如下: Inten ...

  7. android SwipeRefreshLayout嵌套Webview滑动冲突问题解决

    最近有一个需求,需要在网页中实现下拉刷新功能,这里遇到一个坑,加载网页的时候webview向上滑动不了了,看了一下网上的资料尝试过后都没有用,所以在这里做一下记录,希望可以帮到大家,由于两个控件都有滑 ...

  8. Android Scrollview嵌套RecyclerView导致滑动卡顿问题解决(屡试不爽)

    今天开发的一个项目首页,布局还是比较复杂的,各种滑动冲突,(Banner+横向RecyclerView+纵向RecyclerView(item又是横向的RecyclerView)),  最外面的框架用 ...

  9. ScrollView嵌套ListView后,进入页面不从顶部开始显示的问题解决

    ScrollView嵌套ListView后,进入页面不从顶部开始显示的问题解决 首先,正常情况下,如果在ScrollView里嵌套ListView后,会发现ListView只显示1条数据 那么,为了解 ...

最新文章

  1. exchange 2003配置ASSP 反垃圾邮件
  2. 由一次奇怪的编译出错想起的
  3. Linux RAR 安装和使用
  4. linux基础lvm
  5. python 入门第六课 class面向对象OOP
  6. 给刚入职开发人员的几句心里话
  7. python read()为什么返回少一个字符_python-熊猫read_excel(sheet name = None)返回字符串字典,而不是数据帧?...
  8. 内网无纸化会议/智慧教室实时同屏RTSP组播技术方案思考
  9. java 中关键字_java中关键字一览
  10. android功耗(23)---gps定位开发省电要点
  11. 调用模块里的action_初级测试人员进阶必备Python编码模块,看过的都说好
  12. 【报告分享】2020直播电商生态白皮书.pdf(附下载链接)
  13. 6个座位办公室最佳位置_办公室座位最佳位置(讲解)
  14. Spring 学习一 @Autowired
  15. 09. Never call virtual funcitons during construction or destruction
  16. rbf神经网络 c语言,RBF神经网络极简介绍及其算法R语言实现
  17. docker容器中使用vlc将视频文件推成rtsp流
  18. PHP中用while的用法,php while语句的用法
  19. vue 移动端进入页面自动弹出软键盘
  20. 基于 ANSIBLE 自动化运维实践

热门文章

  1. logback指定不同包下的日志输出到不同的文件
  2. Windows 10 下 转移MySQL 8.0的数据库文件夹(靠谱版)
  3. MySQL截取字符串的方法-substring_index
  4. [CodeForces - 950D]A Leapfrog in the Array(思维)
  5. 1.2. MariaDB
  6. 智慧城市开放数据的发展趋势分析及探讨
  7. 在ECSHOP后台左侧导航中增加新菜单
  8. WCF入门学习3-配置文件与部署iis
  9. 2、启动Spring Boot 容器
  10. python斐波那契数列函数,python—函数进阶-斐波那契数列