ScrollView和listview的冲突问题,关于宽度,和滑动
只需要重新listview即可
package com.exmple.listscrow; import java.util.logging.LogManager; import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ListView; public class MyListView extends ListView { int mLastMotionY;
boolean bottomFlag; public MyListView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
} @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// 对height重新赋值
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
/* Integer.MAX_VALUE>> 2 */300, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
} @Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (bottomFlag) {
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(ev);
} @Override
public boolean onTouchEvent(MotionEvent ev) {
int y = (int) ev.getRawY();
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
// 妫f牕鍘涢幏锔藉焻down娴滃娆�,鐠佹澘缍峺閸ф劖鐖�
mLastMotionY = y;
break;
case MotionEvent.ACTION_MOVE:
// deltaY > 0 閺勵垰鎮滄稉瀣箥閸旓拷,< 0閺勵垰鎮滄稉濠呯箥閸旓拷
int deltaY = y - mLastMotionY;
if (deltaY < 0) {
View child = getChildAt(0);
if (child != null) {
if (getLastVisiblePosition() == (getChildCount() - 1) ) {
bottomFlag = true;
getParent().requestDisallowInterceptTouchEvent(true);
} }
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
break;
}
return super.onTouchEvent(ev);
} }
注意:ScrollView只能有一个子类
ScrollView和listview的冲突问题,关于宽度,和滑动的更多相关文章
- [Android] Android最简单ScrollView和ListView滚动冲突解决方案
[Question]问题描述: 单独的ListView列表能自动垂直滚动,但当将ListView嵌套在ScrollView后,会和ScrollView的滚动滑块冲突,造成ListView滑块显示不完整 ...
- ScrollView与ListView的冲突
众所周知ListView与ScrollView都具有滚动能力,对于这样的View控件,当ScrollView与ListView相互嵌套会成为一种问题: 问题一:ScrollView与ListView嵌 ...
- 解决ScrollView与ListView事件冲突
1,在最近做项目的时候使用ScrollView嵌套ListView的时候发现ListView的滑动效果失效,简单的网上搜索了一下,也就有了下面的解决方法,在ListView中设置事件的监听listvi ...
- 关于ScrollView和listview的冲突关于的滑动和宽度
listview和ScrollView嵌套有两个冲突,关于listview显示不全的问题和listview和scrollview的滑动冲突 自定义listview package com.exmple ...
- ScrollView和ListView的冲突问题
在ScrollView添加一个ListView会导致listview控件显示不全,这是因为两个控件的滚动事件冲突导致.所以需要通过listview中的item数量去计算listview的显示高度,从而 ...
- Android ScrollView与ListView的冲突解决办法汇总
1. public void setListViewHeight(){ ListAdapter listadapter = lv.getAdapter(); if (listadapter == n ...
- Android布局中ScrollView与ListView的冲突的最简单方法
看到网上流行的一种使用方法是: public class Utility { public static void setListViewHeightBasedOnChildren(ListView ...
- ScrollView 嵌套ListView 幻灯冲突,和显示不全
import android.content.Context; import android.util.AttributeSet; import android.widget.ListView; /* ...
- android 有弹性的ScrollView 简单实现,与处理ScrollView和ListView,GridView之间的冲突
处理ScrollView和ListView,GridView之间的冲突, 最好的办法就是继承这两个类,重写他们的onMeasure方法即可: ListView: import android.widg ...
随机推荐
- Android带侧滑菜单和ToolBar的BaseActivity
写Android的时候,可能有多个界面.在风格统一的软件中,写Activity时会有很多重复.例如我所在软工课程小组的项目:Github链接 ,里面的TaskListActivity和TeacherL ...
- 常用的 DOCTYPE 声明
常用的 DOCTYPE 声明 HTML 5 <!DOCTYPE html> HTML 4.01 Strict 该 DTD 包含所有 HTML 元素和属性,但不包括展示性的和弃用的元素(比如 ...
- Js闭包常见三种用法
Js闭包特性源于内部函数可以将外部函数的活动对象保存在自己的作用域链上,所以使内部函数的可以将外部函数的活动对象占为己有,可以在外部函数销毁时依然存有外部函数内的活动对象内容,这样做的好处是可 ...
- for memory long term update
xargs是一条Unix和类Unix操作系统的常用命令.它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题. #例如,下面的命令: rm `find /path -type f ...
- Java XML解析工具 dom4j介绍及使用实例
Java XML解析工具 dom4j介绍及使用实例 dom4j介绍 dom4j的项目地址:http://sourceforge.net/projects/dom4j/?source=directory ...
- MySQL配置文件改变了datadir值
从Noinstall Zip Archive中安装MySQL正在从Noinstall软件包安装MySQL的用户可以使用这个说明来手动安装MySQL.从Zip archive 中安装MySQL的 步骤如 ...
- 一个简单驱动的makefile
KVERS = $(shell uname -r) #Kernel modulesobj-m += hello.o build: kernel_modules kernel_modules: make ...
- js判断移动终端url跳转
CODE <script> //判断终端url跳转 function sp_isMobile() { return Boolean(navigator.userAgent.match(/. ...
- javaWeb中servlet开发(4)——servlet跳转
servlet跳转 1.跳转类型 客户端跳转:跳转后地址栏改变,无法传递request范围内属性,是在所有的操作都执行完毕之后才发生跳转的操作,跳转语法是,response.sendRedict() ...
- whether the computers in a cluster share access to the same disks
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION In the literature, cl ...