Android ScrollView嵌套ScrollView滚动的问题解决办法
引用: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滚动的问题解决办法的更多相关文章
- [RN] React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法
React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法 解决办法: 打开android工程,在AndroidManifest.xml中配置如下: <ac ...
- Android bluetoothAdapter.startDiscovery()无法搜索设备问题解决办法
Android6.0以上要定位权限,要手动把手机软件的定位权限打开,又被坑了好长时间
- ScrollView嵌套ListView显示不完全、嵌套TextView不能滚动解决办法
目录: 一.情景说明 二.最初做法 三.解决办法 一.情景说明 1.情景 最近项目刚好有一个需求,需要在一个界面中用ScrollView嵌套一个滚动的TextView和一个listView ...
- Scrollview 嵌套 RecyclerView 及在Android 5.1版本滑动时 惯性消失问题
标签:scrollview android 滑动 嵌套 scrollview 嵌套recyclerview 时,recyclerview不显示,这就需要我们自己计算recyclerview ...
- Android 开发遇到的问题及解决办法
Failed to resolve: com.android.support:appcompat-v7:23.4.0 问题解决办法: 1.在Android SDK Manager中找到对应的SDK版本 ...
- Android开发:ScrollView嵌套GridView的解决办法
Android开发:ScrollView嵌套GridView的解决办法 前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便 ...
- Android ScrollView 嵌套 ListView、 ListView 嵌套ScrollView Scroll事件冲突解决办法
本人菜鸟一名,最近工作了,开始学习Android. 最近在做项目的时候,UX给了个design,大概就是下拉刷新的ListView中嵌套了ScrollView,而且还要在ScrollView中添加动画 ...
- Android Scrollview嵌套RecyclerView导致滑动卡顿问题解决
一个比较长的界面一般都是Scrollview嵌套RecyclerView来解决.不过这样的UI并不是我们开发人员想看到的,实际上嵌套之后.因为Scrollview和RecyclerView都是滑动控件 ...
- 【Android - 问题解决】之ScrollView嵌套ListView时总是自动滑动到ListView顶部的问题
最近做了一个项目,里面有一个ScrollView嵌套ListView的布局. 做出来之后发现,进入这个界面之后,总是自动滑动到ListView的顶部,而ScrollView中位于ListView上面的 ...
随机推荐
- [转]gluProject 和 gluUnproject 的详解
gluProject 和 gluUnproject 的详解 简介: 三维空间中,经常需要将 3D 空间中的点转换到 2D(屏幕坐标),或者将 2D 点转换到 3D 空间中.当你使用 OpenGL 的时 ...
- MySQL修改密码和忘记ROOT密码
1.关闭数据库 脚本:[root@mysql etc]# service mysql stop 2.使用脚本: mysqld_safe --skip-grant-tables 启动数据库 使用/usr ...
- Hibernate的Configuration和SessionFactiory
Configuration: Configuration是hibernate的入口,负责管理Hibernate的配置信息,这些配置信息都是从配置文件hibernate.cfg.xml或者Hiberna ...
- 【Cesium】坐标理解(转)
https://blog.csdn.net/qq_34149805/article/details/78393540 1. 经纬度转换为世界坐标 第一种方式:直接转换: Cesium.Cartesia ...
- DATAGUARD的搭建
ORACLE Data Guard 理论知识 请查看此blog :http://blog.csdn.net/haibusuanyun/article/details/11519241 Oracle D ...
- Nginx 过期时间
客户端(浏览器)访问服务器上的资源后,会缓存在浏览器中,对于一些经常变更的静态资源,我们可以设置缓存时间,也就是设置静态资源的过期时间 [root@localhost ~]$ cat /usr/loc ...
- transformNative_libsWithStripDebugSymbolForDebug
local.properties #ndk.dir=C\:\\My_other\\Android_SDK\\ndk-bundle 把NDK注释掉就ok了
- SpringBoot集成Mybatis并具有分页功能PageHelper
SpringBoot集成Mybatis并具有分页功能PageHelper 环境:IDEA编译工具 第一步:生成测试的数据库表和数据 SET FOREIGN_KEY_CHECKS=0; ...
- 【转】VC 隐藏模块、MFC 改变窗口类名
[转]VC 隐藏模块 void HideDll() { HMODULE hMod = ::GetModuleHandle("MyHook.dll"); PLIST_ENTRY He ...
- HTML-锚点-JS跳转锚点
window.location.hash使用说明,这篇写的挺详细的 http://www.cnblogs.com/nifengs/p/5104763.html a标签的话是 name,div呢是id, ...