RecyclerView 在ScrollView部分机型无法下拉显示不全(兼容问题)
来源:互联网 发布:java向数据库添加数据 编辑:程序博客网 时间:2024/05/22 07:57
本文出自:http://blog.csdn.net/dt235201314/article/details/53006062
一丶简述
上个月一篇博客没写,原因忙成狗,手上一直有任务,总结下来,能写出几篇博客
二丶问题描述
ScrollView套RecyclerView展示数据。
三星,华为等较新热门机型测试无BUG,测试组部分手机无法下拉显示更多。
三丶分析
1.部分手机无法下拉,表示兼容性问题
2.好几个页面都是这种类型但惟独两个页面不行,特点都是RecyclerView + ScrollView不行,而ListView + ScrollView可以。
3.Android群讨论,有用信息: 1.RecyclerView + ScrollView和ListView + ScrollView都可能会出现显示不全问题,各自需要重写对应方法
2.RecyclerView V7包就是解决兼容性包。
3.RecyclerView 属性比ListView丰富,大有替代之势。
四丶博客参考
鸿洋大神的(RecyclerView基本用法与自定义)
Android 自定义RecyclerView 实现真正的Gallery效果
关于滑动冲突(这个是与问题最接近,也讲得最有道理的)
Scrollview 嵌套 RecyclerView 及在Android 5.1版本滑动时 惯性消失问题
五丶问题解决
快发版了,处于稳定考虑,直接将RecyclerView改成ListView
注意点:重写ListView的onMeasure
public class ExpandListView extends ListView { public ExpandListView(Context context) { super(context); } public ExpandListView(Context context, AttributeSet attrs) { super(context, attrs); } public ExpandListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public ExpandListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2 , MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); }}
ListView填充方法:
public void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); params.height += 5;//if without this statement,the listview will be a little short listView.setLayoutParams(params);}
总结:第一次遇到这种问题,查阅了很多相关的解决办法,遗憾的是群里大神跟我讲解源码的时候蒙逼了
有时间了我要去深挖源码。
- RecyclerView 在ScrollView部分机型无法下拉显示不全(兼容问题)
- Unity3d中文在部分机型显示不全解决方案
- ScrollView嵌套RecyclerView显示不全
- scrollView嵌套recyclerView (再嵌套recyclerView )显示不全
- Android 6.0+ RecyclerView嵌套在ScrollView中显示不全
- scrollView嵌套recyclerView 显示不全(已解决)
- scrollView嵌套recyclerView 显示不全(已解决)
- ScrollView嵌套Listview/RecyclerView内容显示不全
- 关于Scrollview嵌套RecyclerView高度显示不全
- Scrollview嵌套RecyclerView高度显示不全
- Android中Scrollview嵌套recyclerView,recyclerview设置wrapcontent无法显示以及显示后item显示不全的问题
- ScrollView嵌套RecyclerView 导致RecyclerView数据显示不全
- Android 6.0以上系统的 RecyclerView 在HorizontalScrollView或者Scrollview中显示不全问题
- ScrollView 嵌套 RecyclerView 高度自适应,item显示不全 问题
- 解决ScrollView嵌套RecyclerView时item显示不全的问题
- Fragment里ScrollView嵌套RecyclerView显示不全的问题
- 解决android6.0ScrollView嵌套RecyclerView显示不全问题
- ScrollView和RecyclerView嵌套使用显示不全问题解决
- Windows 使用dryrun 运行github上的Android程序之环境搭建
- 基于SSH的员工管理系统(一)——包结构
- vim技巧
- gdi 句柄泄漏之坑
- 基于CNN的性别、年龄识别
- RecyclerView 在ScrollView部分机型无法下拉显示不全(兼容问题)
- Revit2016 外部工具添加 ---win10
- jQuery Ajax 异步加载显示等待效果代码分享
- 关于maven的jar包下找不到类的一种可能
- canon相机镜头协议数据用python进行格式化
- iOS UIScrollView 的下拉刷新和上拉加载的实现
- 保存图片到相册
- 查看Oracle中是否有锁表的sql
- Qt MetaObject 详解之二:QMeta数据以及数据结构信息