引用: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….

    <ScrollView
android: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"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"> <ScrollView
android: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"> <TextView
android: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 view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});

Done …

Android ScrollView嵌套ScrollView滚动的问题解决办法的更多相关文章

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

    React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法 解决办法: 打开android工程,在AndroidManifest.xml中配置如下: <ac ...

  2. Android bluetoothAdapter.startDiscovery()无法搜索设备问题解决办法

    Android6.0以上要定位权限,要手动把手机软件的定位权限打开,又被坑了好长时间

  3. ScrollView嵌套ListView显示不完全、嵌套TextView不能滚动解决办法

    目录: 一.情景说明 二.最初做法 三.解决办法 一.情景说明 1.情景       最近项目刚好有一个需求,需要在一个界面中用ScrollView嵌套一个滚动的TextView和一个listView ...

  4. Scrollview 嵌套 RecyclerView 及在Android 5.1版本滑动时 惯性消失问题

    标签:scrollview   android   滑动   嵌套 scrollview 嵌套recyclerview 时,recyclerview不显示,这就需要我们自己计算recyclerview ...

  5. Android 开发遇到的问题及解决办法

    Failed to resolve: com.android.support:appcompat-v7:23.4.0 问题解决办法: 1.在Android SDK Manager中找到对应的SDK版本 ...

  6. Android开发:ScrollView嵌套GridView的解决办法

    Android开发:ScrollView嵌套GridView的解决办法   前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便 ...

  7. Android ScrollView 嵌套 ListView、 ListView 嵌套ScrollView Scroll事件冲突解决办法

    本人菜鸟一名,最近工作了,开始学习Android. 最近在做项目的时候,UX给了个design,大概就是下拉刷新的ListView中嵌套了ScrollView,而且还要在ScrollView中添加动画 ...

  8. Android Scrollview嵌套RecyclerView导致滑动卡顿问题解决

    一个比较长的界面一般都是Scrollview嵌套RecyclerView来解决.不过这样的UI并不是我们开发人员想看到的,实际上嵌套之后.因为Scrollview和RecyclerView都是滑动控件 ...

  9. 【Android - 问题解决】之ScrollView嵌套ListView时总是自动滑动到ListView顶部的问题

    最近做了一个项目,里面有一个ScrollView嵌套ListView的布局. 做出来之后发现,进入这个界面之后,总是自动滑动到ListView的顶部,而ScrollView中位于ListView上面的 ...

随机推荐

  1. 如果返回结构体类型变量(named return value optimisation,NRVO) ------ 续

    为什么? <More C++ idioms>: 3. Algebraic Hierarchy 程序执行的流程与自己想的不一样: Number Number::makeReal(double ...

  2. JWT全面解读、使用步骤

    JWT全面解读JWT全面解读前言JWT基本使用在pom.xml引入java-jwt示例如下概念介绍JWT消息构成头部playload标准中注册的声明 (建议但不强制使用)自定义数据签名signatur ...

  3. ApkTool反编译和重新打包

    有时会需要反编译APK,各人有各人的原因,你都懂的…… 准备工作: 下载APKTool,通过下面这个连接进行下载,https://code.google.com/p/android-apktool/d ...

  4. jqgrid api

    http://www.cnblogs.com/onflying/archive/2013/05/14/3077505.html

  5. Linux中实现多网卡绑定总结

    在Linux中实现多网卡绑定 一.原理介绍: 1.什么是bonding? Linux bonding 驱动提供了一个把多个网络接口设备捆绑为单个的网络接口设置来使用.用于网络负载均衡及网络冗余: Li ...

  6. 8 -- 深入使用Spring -- 4...5 AOP代理:基于注解的“零配置”方式

    8.4.5 基于注解的“零配置”方式 AspectJ允许使用注解定义切面.切入点和增强处理,而Spring框架则可识别并根据这些注解来生成AOP代理.Spring只是使用了和AspectJ 5 一样的 ...

  7. GOF---Java开发中的23种设计模式详解

    表点 设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式 ...

  8. 产品半夜发现bug让程序员加班,程序员应如何回应?

    群友半夜2点被产品叫起来改东西,然后他打车去公司加班,群友愤慨,特为此创作一个小段子 产品:XXX出bug了你赶紧看看 修复一下 开发:我宿舍没电脑 没网络啊 产品:你看看周围有没有网吧远程一下 或者 ...

  9. iOS NSError

    写在前面 在iOS开发中,NSError的使用非常常见,使用也比较简单,也正因为简单,所以对这一部分知识不甚注重.但是近期在做app底层网络封装时发现了一些问题.我使用的网络框架是AFNetworki ...

  10. RPM常用命令解释

    RPM软件包管理器,英文:RPM Package Manager(原Red Hat Package Manager,现在是一个递归缩写) -i安装rpm包 -u升级rpm包 -q查询已安装的软件信息 ...