我们看下图:

不管怎么滑动都无法显示listview的剩余数据,只能显示一条,我们看下布局,ScrollView里面嵌套ListView

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@null"android:orientation="vertical"><include layout="@layout/common_title_view" /><ScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:scrollbars="none"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:background="@null"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="@dimen/dp_44"android:background="@color/colorMain"><ImageViewandroid:id="@+id/iv_pre"android:layout_width="0dp"android:layout_height="match_parent"android:layout_centerVertical="true"android:layout_weight="1"android:background="@null"android:paddingRight="@dimen/dp_60"android:scaleType="centerInside"android:src="@mipmap/ic_left_arrow" /><TextViewandroid:id="@+id/tv_current_time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:text="1970-01-01"android:textColor="@color/white" /><ImageViewandroid:id="@+id/iv_more"android:layout_width="0dp"android:layout_height="match_parent"android:layout_centerVertical="true"android:layout_weight="1"android:background="@null"android:paddingLeft="@dimen/dp_60"android:scaleType="centerInside"android:src="@mipmap/ic_right_arrow" /></LinearLayout><com.Yhsh.mobile.uiwidget.widget.calendar.CalendarLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:orientation="vertical"app:calendar_show_mode="only_week_view"app:default_status="shrink"><com.Yhsh.mobile.uiwidget.widget.calendar.CalendarViewandroid:id="@+id/scheduling_calendar_view"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@color/colorMain"app:calendar_height="60dp"app:current_day_lunar_text_color="@color/white"app:current_day_text_color="@color/white"app:current_month_text_color="@color/white"app:day_text_color="@color/white"app:day_text_size="14sp"app:lunar_text_size="14sp"app:month_view_show_mode="mode_only_current"app:other_month_text_color="@color/white"app:selected_lunar_text_color="@color/white"app:selected_text_color="@color/white"app:week_background="@color/colorMain"app:week_start_with="sun"app:week_text_color="@color/white"app:week_text_size="14sp" /></com.Yhsh.mobile.uiwidget.widget.calendar.CalendarLayout><TextViewandroid:id="@+id/tv_scheduling_date"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="15dp"android:paddingLeft="15dp"android:paddingRight="15dp"android:textColor="@color/black" /><ListViewandroid:divider="@null"android:id="@+id/lv_replace_over_time_list"android:layout_width="match_parent"android:layout_height="wrap_content" /></LinearLayout></ScrollView></LinearLayout>

实际上解决方法非常简单如下:

 /*** 设置点击日期显示班次的方法** @param selectPosition 选中的日期*/private void setSelectData(int selectPosition) {myReplaceAdapter = new MyReplaceAdapter(mSchedulingTimeMap, selectPosition);lvReplaceOverTimeList.setAdapter(myReplaceAdapter);setHeight();}/*** 解决ListView和ScrollView滑动冲突的bug* lvReplaceOverTimeList 控件listView* myReplaceAdapter adapter*/public void setHeight() {int height = 0;int count = myReplaceAdapter.getCount();for (int i = 0; i < count; i++) {View temp = myReplaceAdapter.getView(i, null, lvReplaceOverTimeList);temp.measure(0, 0);height += temp.getMeasuredHeight();}ViewGroup.LayoutParams params = lvReplaceOverTimeList.getLayoutParams();params.width = ViewGroup.LayoutParams.FILL_PARENT;params.height = height;lvReplaceOverTimeList.setLayoutParams(params);}

再来看下是否可以滑动:

看到了吧,余下的数据显示出来了

Android开发之解决ListView和ScrollView滑动冲突的方法相关推荐

  1. 【Android 手势冲突】Colin带你彻底解决RecyclerView与ScrollView滑动冲突问题,并实现RecyclerView悬停导航栏(附demo哦)

    在新一期的需求中,产品要求我们做出和美团某个页面类似的功能,即一个页面包含在scrollView中,上面一个部分放置一些常用的广告banner.宫格tab等,下面放置一个RecyclerView用于展 ...

  2. 使用LinearLayout实现ListView,解决ListView和ScrollView滚动冲突

    在项目中,我们常常会遇到一个ScrollView里面会嵌套ListView的情况,但往往你会发现,ListView和ScrollView的滚动时间会有冲突问题,造成ListView不能完全显示.虽然网 ...

  3. 解决SwipeRefreshLayout与Banner滑动冲突

    import android.content.Context; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import ...

  4. Android取消RecyclerView、ListView、ScrollView、HorizontalScrollView滑动到边缘闪现灰白色水波纹动画

    Android取消RecyclerView.ListView.ScrollView.HorizontalScrollView滑动到边缘闪现灰白色水波纹动画 标准的Android RecyclerVie ...

  5. android listview下拉动画效果,Android开发中利用ListView实现一个渐变式的下拉刷新动画...

    Android开发中利用ListView实现一个渐变式的下拉刷新动画 发布时间:2020-11-23 16:50:31 来源:亿速云 阅读:80 作者:Leah 本篇文章给大家分享的是有关Androi ...

  6. android listview ontouchlistener,Android ListView监听滑动事件的方法(详解)

    ListView的主要有两种滑动事件监听方法,OnTouchListener和OnScrollListener 1.OnTouchListener OnTouchListener方法来自View中的监 ...

  7. 【Cocos2d-x游戏开发】解决Cocos2d-x中文乱码的三种方法

    [Cocos2d-x游戏开发]解决Cocos2d-x中文乱码的三种方法 参考文章: (1)[Cocos2d-x游戏开发]解决Cocos2d-x中文乱码的三种方法 (2)https://www.cnbl ...

  8. iOS开发中解决第三方静态库符号冲突的终极方案

    iOS开发中解决第三方静态库符号冲突的终极方案 背景 在iOS开发的时候,经常会使用各种第三方静态库,这些库内部可能会打包了相同的第三方库.那么在链接的时候就会发生符号冲突. 例如:A厂商提供的lib ...

  9. 解决3G上网卡与VM7冲突的方法(华为EC122 3G上网卡)

    解决3G上网卡与VM7冲突的方法(华为EC122 3G上网卡) 故障描述: 我的笔记本一直使用电信的华为EC122 3G上网卡,最近安装了VM 7,再插上上网卡,本地电脑直接无法发现该硬件,在虚拟机中 ...

最新文章

  1. Android应用屏幕适应问题的解决
  2. 猫头鹰的深夜翻译:API网关的重要性
  3. 理解ATL中的一些汇编代码
  4. MyEclipse导入新项目后,不能发布到Tomcat
  5. 如何关闭SAP Fiori的病毒扫描设置
  6. Android 百度地图开发(一)
  7. javascript基础--数组排序
  8. linux系统构架ftp,用Linux系统构建高效FTP服务器
  9. Nginx解决前端调用后端接口跨域问题
  10. 流媒体服务器设计文档,流媒体服务器设文档.doc
  11. 失范的数字货币量化市场:积弊成疾,洗牌将至 |链捕手
  12. ‍炮灰模型---------- 对女生选择追求者的数学模型的建立
  13. 卸载mysql数据库报错_完全卸载mysql数据库图文教程
  14. 真无线蓝牙耳机,享受高品质杜比音效
  15. Backstepping(反步法)控制初学讲解
  16. 小程序跳转公众号关注页面的两种方法
  17. easyx的使用(1)
  18. Tomcat架构详解
  19. vue实现水平时间线与蛇形时间线
  20. Android音视频——MediaPlayerService

热门文章

  1. anglar ajax执行2次的原因,angular2 router’解决问题被执行两次
  2. tensorflow环境下的识别食物_在TensorFlow+Keras环境下使用RoI池化一步步实现注意力机制...
  3. python3解释器执行long(10)的结果为_Python3解释器执行'AB2C3D'.lower().title()的结果是( )。...
  4. 第一阶段冲刺 第二天
  5. ubuntu安装扩展在phpinfo显示不出来的解决办法
  6. BZOJ 3224 普通平衡树 treap or vector
  7. Activity的生命周期及各生命周期方法的作用
  8. 《Delphi XE6 android 编程入门教程》推荐
  9. IOS-UIDynamic
  10. 如何自动判断url中汉字的编码格式