只需要重新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的冲突问题,关于宽度,和滑动的更多相关文章

  1. [Android] Android最简单ScrollView和ListView滚动冲突解决方案

    [Question]问题描述: 单独的ListView列表能自动垂直滚动,但当将ListView嵌套在ScrollView后,会和ScrollView的滚动滑块冲突,造成ListView滑块显示不完整 ...

  2. ScrollView与ListView的冲突

    众所周知ListView与ScrollView都具有滚动能力,对于这样的View控件,当ScrollView与ListView相互嵌套会成为一种问题: 问题一:ScrollView与ListView嵌 ...

  3. 解决ScrollView与ListView事件冲突

    1,在最近做项目的时候使用ScrollView嵌套ListView的时候发现ListView的滑动效果失效,简单的网上搜索了一下,也就有了下面的解决方法,在ListView中设置事件的监听listvi ...

  4. 关于ScrollView和listview的冲突关于的滑动和宽度

    listview和ScrollView嵌套有两个冲突,关于listview显示不全的问题和listview和scrollview的滑动冲突 自定义listview package com.exmple ...

  5. ScrollView和ListView的冲突问题

    在ScrollView添加一个ListView会导致listview控件显示不全,这是因为两个控件的滚动事件冲突导致.所以需要通过listview中的item数量去计算listview的显示高度,从而 ...

  6. Android ScrollView与ListView的冲突解决办法汇总

    1. public  void setListViewHeight(){ ListAdapter listadapter = lv.getAdapter(); if (listadapter == n ...

  7. Android布局中ScrollView与ListView的冲突的最简单方法

    看到网上流行的一种使用方法是: public class Utility { public static void setListViewHeightBasedOnChildren(ListView ...

  8. ScrollView 嵌套ListView 幻灯冲突,和显示不全

    import android.content.Context; import android.util.AttributeSet; import android.widget.ListView; /* ...

  9. android 有弹性的ScrollView 简单实现,与处理ScrollView和ListView,GridView之间的冲突

    处理ScrollView和ListView,GridView之间的冲突, 最好的办法就是继承这两个类,重写他们的onMeasure方法即可: ListView: import android.widg ...

随机推荐

  1. Redis整合Spring结合使用缓存实例(三)

    一.Redis介绍 什么是Redis? redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set( ...

  2. js打印功能

    1.window.print方式: jsp页面 打印按钮:       <input type="button" value="打印" onclick=& ...

  3. TCP和UDP的聊天

    TCP聊天 TCP(Transmission Control Protocol,传输控制协议)是基于连接的协议. 1.一个TCP连接必须要经过三次"对话"才能建立起来,其中的过程非 ...

  4. Qt 按钮事件不响应

    在Qt中,我们设置好按钮的相应事件,连好信号槽,声明什么的也没什问题,但为什么点击按钮就是没有反应,检查了半天终于发现原来是子面板上也有一个相同名称的按钮,一般来说两个面板不为父子关系的时候,分别在不 ...

  5. [LintCode] Happy Number 快乐数

    Write an algorithm to determine if a number is happy. A happy number is a number defined by the foll ...

  6. Mysql的实时同步 - 双机互备

    设置方法: 步一设 A 服务服 (192.168.1.43) 上用户为 backup, 123456 , 同步的数据库为test; B 服务服 (192.168.1.23) 上用户为 root, 12 ...

  7. Oracle RAC的日志体系

    Oracle Clusterware 不像数据库那样,有丰富的视图.工具可以用来辅助诊断,它的日志和trace文件是唯一的选择.但不像Oracle只有alert日志和几种trace文件,Oracle ...

  8. Python 基础 - 随机列表最大的两个值

    # -*- coding: utf-8 -*- #author:v def sywmemeda(l): #list 冒泡排序 length = len(l) for i in range(length ...

  9. JAVA面向对象程序设计——实验报告

  10. Android课程---表格布局TableLayout

    特别注意:由于表格布局继承自线性布局,因此并不显示表格线 示例代码: <?xml version="1.0" encoding="utf-8"?> ...