ScrollView嵌套ListView 两者滚动互不影响
来源:互联网 发布:cf踢腿外设软件 编辑:程序博客网 时间:2024/05/20 21:18
一个ScrollView中间嵌套ListView,当手指滑动ListView的时候,它滚动,当手指滑动ListView以外的部分ScrollView滚动。
布局代码
<?xml version="1.0" encoding="utf-8"?><com.cn.horizon.life.widgets.MyScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="1000dp" android:paddingTop="80dp" android:background="#CDCDCD"> <com.cn.horizon.life.widgets.MyListView android:id="@+id/lvList" android:layout_width="match_parent" android:layout_height="390dp" android:background="#ff0" /> </RelativeLayout></com.cn.horizon.life.widgets.MyScrollView>
MyScrollView代码如下
import android.content.Context;import android.os.Build;import android.support.annotation.RequiresApi;import android.util.AttributeSet;import android.view.MotionEvent;import android.view.View;import android.widget.AbsListView;import android.widget.HorizontalScrollView;import android.widget.ListView;import android.widget.ScrollView;public class MyScrollView extends ScrollView { public MyScrollView(Context context) { super(context); } public MyScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { boolean intercept = false; switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: intercept = false; break; case MotionEvent.ACTION_MOVE: View child = getFocusedChild(); if (child instanceof AbsListView) intercept = true; else intercept = false; break; case MotionEvent.ACTION_UP: intercept = false; break; } return intercept; }}
1 0
- ScrollView嵌套ListView 两者滚动互不影响
- HorizonScrollView嵌套ListView 两者滚动互不影响
- ScrollView嵌套ListVIew两者之间滑动问题
- ScrollView与ListView的焦点问题,互相滑动互不影响
- scrollview嵌套listview,listview不滚动问题
- ScrollView嵌套Listview,scrollview总是滚动到listview的位置
- ScrollView嵌套Gridview或者listview滚动问题
- android scrollview 嵌套自适应 listview 自动滚动
- ScrollView嵌套ListView滚动冲突的解决方案
- Android ListView中嵌套ScrollView,ScrollView不能滚动
- ScrollView嵌套ListView显示不完全、嵌套TextView不能滚动解决办法
- ScrollView嵌套ListView显示不完全、嵌套TextView不能滚动解决办法
- ScrollView嵌套ListView显示不完全、嵌套TextView不能滚动解决办法
- ScrollView内嵌套ListView时禁止ListView的滚动
- ScrollView内嵌套ListView时禁止ListView的滚动
- Android经常遇到Scrollview嵌套Listview造成listview无法滚动
- scrollView中嵌套ListView,ListView不能滚动的问题
- Android - ScrollView嵌套ListView~使ListView不滚动
- C++定义与声明 区别
- Java 类的初始化顺序 附测试代码
- SEO网站优化的7个常见技巧
- 我的大学四年总目标
- HPUoj 瞎子与瘸子的故事 ( BFS
- ScrollView嵌套ListView 两者滚动互不影响
- STM32F407ZGT6实现输入捕获RX1002八路PWM信号
- HTTP协议学习笔记
- Android中系统状态栏的隐藏和显示
- c++作业3
- 动态规划----Amous_of_degrs
- spring mvc工作流程概述
- vs2013无法打开vs2010的解决方案
- 使用scala的Actor模拟计算多文件WordCount