引用: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=”fill_parent”
android:layout_height=”wrap_content”
android:layout_weight=”1″
android:background=”@drawable/dotted_bg”
android:focusableInTouchMode=”false”>
<LinearLayout />
<LinearLayout />
<LinearLayout >
<ScrollView android:id=”@+id/child_scroll”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:background=”@drawable/text_box_bg”>
<TextView android:id=”@+id/text_description”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:textColor=”@color/gray”
android:textSize=”12dip”
android:padding=”5dip”
android:scrollbars=”vertical”/>
<!–ScrollView>
</LinearLayout>
</ScrollView>
Step 1 : Provide unique id to both the scrollview.
Step 2 : get reference of that two scrollview in your activity.
parentScroll=(ScrollView)findViewById(R.id.parent_scroll);
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) {
Log.v(TAG,”PARENT TOUCH”);
findViewById(R.id.child_scroll).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScroll.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
Log.v(TAG,”CHILD TOUCH”);
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
Done …
分享到:
相关推荐
ScrollView嵌套GridView不能滚动的问题解决方案,重写GridView方法使其不能滚动,就不会与ScrollView的滚动冲突,从而解决问题
本篇文章主要介绍了Android ScrollView嵌套横向滑动控件时冲突问题,具有一定的参考价值,有兴趣的可以了解一下
您可能感兴趣的文章:Android ScrollView 下嵌套 ListView 或 GridView出现问题解决办法Android中ScrollView嵌套GridView的解决办法Android 中ScrollView嵌套GridView,ListView的实例Android 中
前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便会出问题,即GridView会显示不全,为了解决这个问题查了N多资料,某个谷歌的官方回复竟然是GridView...
Android ScrollView 下嵌套 ListView 或 GridView出现问题解决办法 ScrollView 下嵌套 ListView 或 GridView 会发列表现数据只能显示一行。因为他们都是滚动结构,两个滚动条放到一起就会引起冲突。 解决此问题可以...
前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便会出问题,即GridView会显示不全。 找到大家的通用解决办法。记录一下。 解决办法,自定义一个...
解决复杂布局,scrollview嵌套ListView滑动性能的问题,提供下拉刷新和暴露对外操作listview控件UI的方法,同步博文:http://blog.csdn.net/qq_28690547/article/details/50792439
RecyclerView滑动固定/悬停/折叠分组列表标题,NestScrollView折叠布局,解决和RecyclerView的滑动冲突, 自定义View(柱状直方图、金融收益图、无线轮播图、带Icon的TabView),WebView预加载,主流首页框架的多种...
Android ListView与ScrollView冲突的解决方法总结 众所周知ListView与ScrollView都具有滚动能力,对于这样的View控件,当ScrollView与ListView相互嵌套会成为一种问题: 问题一:ScrollView与ListView嵌套导致...
RecyclerView嵌套RecyclerView滑动冲突
完美解决recyclerview item上面包含多个edittext导致数据错乱,和滑动卡顿问题
ScrollView可实现控件在超出屏幕范围的情况下滚动显示。 用法:在XML文件中将需滚动的控件包含在ScrollView中,当控件超出屏幕范围时可通过滚动查看;ScrollView也提供了一些方法来控制自身的显示情况。 1....
本篇文章主要介绍了Android Webview与ScrollView的滚动兼容及留白处理的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
且 HorizontalScrollView 和 ScrollView 里面最多只能包含一个组件(当然组件里面还可以嵌套组件)。它们不同的是 HorizontalScrollView 用于添加水平滚动,而 ScrollView 用于添加垂直滚动。 突然间想到 做一个屏幕...
像 ScrollView 这样的滚动小部件不应包含任何嵌套的滚动小部件,因为这存在各种可用性问题 但如果你真的想要,这个可以是一个解决方案。 截图 使用普通的 ListView 使用这个 WrapContentListView 用法 < org ....
Android 升级版 SwipeRefreshLayout,支持下拉刷新(Refresh)和上拉加载更多(Loadmore),支持自定义HeaderView和FooterView,支持RecyclerView、ScrollView嵌套滚动,支持任何View和Layout,支持自定义动画
要想实现滚动显示,layout布局里必须要使用HorizontalScrollView,才能实现横向滑动,但HorizontalScrollView标签里要嵌套一个LinearLayout布局 activity_main.xml,如下: <LinearLayout xmlns:android=...