引用: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. 深入理解Java虚拟机(一)

    一.运行时数据区域 ​ 1.程序计数器: 当前线程执行字节码的行号指示器(通过改变计数器的值来选择下条需要执行的字节码指令) 每个线程有独立的程序计数器(线程私有,为了切换线程时能恢复到挣钱的执行位置 ...

  2. tornado入门1

    Tornado web server 是使用Python编写出來的一个极轻量级.高可伸缩性和非阻塞IO的Web服务器软件,著名的 Friendfeed 网站就是使用它搭建的. Tornado 跟其他主 ...

  3. python中的List 和 Tuple

    #-*- coding:UTF-8 -*- classmates=["Michael","Bob","Tracy"] print(class ...

  4. css 中的相对定位和绝对定位

    1.默认不写position的话,值为static. 2.相对定位:相对于元素自己本身的位置偏移,虽然位置偏移,但元素本身占据的空间并不释放. 3.绝对定位:相对于离它最近的,position不为st ...

  5. jsavascript 面向对象的下拉菜单

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  6. 解决 iOS7 通过tag 找不到 UITableViewCell 的子控件(转)

    转自:http://www.cnblogs.com/waiwaibuzhidao/p/3340400.html 当iOS7问世,程序的世界就混乱了,以前良好的程序,现在是一塌糊涂,于是只能把问题一个一 ...

  7. Android零碎知识点 1

    Android零碎知识点 1   Android在2.3版本上开始支持KeyEvent.KEYCODE_PAGE_DOWN以及KeyEvent.KEYCODE_PAGE_UP的操作.   Androi ...

  8. cocos2d-x 3.0 在C++中调用lua函数(2)

    个人觉得3.0里面, 在C++下面调用lua函数很不方便, 所以就扩展了一个类, 继承自LuaStack, 代码和使用方式如下: #ifndef __CC_LUA_STACKEX_H_ #define ...

  9. iOS UTI(统一类型标识)

    同一类型标识符(Uniform Type Identifier,UTI)代表IOS信息共享的中心组件.可以把它看成下一代的MIME类型.UTI是标识资源类型(比如图像和文本)的字符串,他们制定哪些类型 ...

  10. Spring getBean 首字母大小写问题

    如果类第一个字母大写第二个小写,那么首字母小写获取bean 如果第一个和第二个字母都是大写的,那个获取bean首字母要大写