解决RecyclerView条数显示不全问题

2024-08-31 09:38

本文主要是介绍解决RecyclerView条数显示不全问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

小知识解决大问题,问题处理+经验分享,大家好,我是时代新人!今天给大家分享一条小经验,请往下看:

多个RecyclerView同时使用的时候,比如线性垂直排布三个RecyclerView,那么会出现一个问题就是第一个RecyclerView的数据条数显示不全,只能显示一屏的内容,比如有10条数据,一屏只能显示5条,那么第一个RecyclerView就只显示5条数据,然后就显示下一个RecyclerView的数据了

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:visibility="visible"><!-- 第一部分 --><RelativeLayoutandroid:id="@+id/rl_theCaseMore"android:layout_width="match_parent"android:layout_height="@dimen/dimen_40dp"android:paddingLeft="@dimen/dimen_14dp"android:paddingRight="@dimen/dimen_14dp"android:background="@color/gray_F7"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:textSize="@dimen/sp_14"android:textColor="@color/black"android:text="@string/the_case"/><ImageViewandroid:id="@+id/img_theCaseMore"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:src="@mipmap/vibration_college_icon_more"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_toLeftOf="@+id/img_theCaseMore"android:layout_marginRight="@dimen/dp_4"android:text="@string/more"android:textSize="@dimen/sp_12"android:textColor="@color/gray_7C"/></RelativeLayout><android.support.v7.widget.RecyclerViewandroid:id="@+id/rv_theBaseSearched"android:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="@dimen/dimen_14dp"android:paddingRight="@dimen/dimen_14dp"/><!-- 第二部分 --><RelativeLayoutandroid:id="@+id/rl_productIntroductionMore"android:layout_width="match_parent"android:layout_height="@dimen/dimen_40dp"android:paddingLeft="@dimen/dimen_14dp"android:paddingRight="@dimen/dimen_14dp"android:background="@color/gray_F7"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:textSize="@dimen/sp_14"android:textColor="@color/black"android:text="@string/product_introduction"/><ImageViewandroid:id="@+id/img_productIntroductionMore"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:src="@mipmap/vibration_college_icon_more"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_toLeftOf="@+id/img_productIntroductionMore"android:layout_marginRight="@dimen/dp_4"android:text="@string/more"android:textSize="@dimen/sp_12"android:textColor="@color/gray_7C"/></RelativeLayout><android.support.v7.widget.RecyclerViewandroid:id="@+id/rv_productIntroductionSearched"android:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="@dimen/dimen_14dp"android:paddingRight="@dimen/dimen_14dp"/><!-- 第三部分 --><RelativeLayoutandroid:id="@+id/rl_vibrationBasedMore"android:layout_width="match_parent"android:layout_height="@dimen/dimen_40dp"android:paddingLeft="@dimen/dimen_14dp"android:paddingRight="@dimen/dimen_14dp"android:background="@color/gray_F7"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:textSize="@dimen/sp_14"android:textColor="@color/black"android:text="@string/vibration_based"/><ImageViewandroid:id="@+id/img_vibrationBasedMore"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:src="@mipmap/vibration_college_icon_more"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_toLeftOf="@+id/img_vibrationBasedMore"android:layout_marginRight="@dimen/dp_4"android:text="@string/more"android:textSize="@dimen/sp_12"android:textColor="@color/gray_7C"/></RelativeLayout><android.support.v7.widget.RecyclerViewandroid:id="@+id/rv_vibrationBasedSearched"android:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="@dimen/dimen_14dp"android:paddingRight="@dimen/dimen_14dp"/></LinearLayout></ScrollView>

解决办法,是给第一个RecyclerView的外层套一层线性布局就好了,像下面这样,只处理第一个RecyclerView就行,后面两个RecyclerView显示是正常的不用管。亲测有效,如果您有更好方法欢迎讨论

        <RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><android.support.v7.widget.RecyclerViewandroid:id="@+id/rv_theBaseSearched"android:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="@dimen/dimen_14dp"android:paddingRight="@dimen/dimen_14dp"/></RelativeLayout>

 

这篇关于解决RecyclerView条数显示不全问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1123538

相关文章

SpringBoot排查和解决JSON解析错误(400 Bad Request)的方法

《SpringBoot排查和解决JSON解析错误(400BadRequest)的方法》在开发SpringBootRESTfulAPI时,客户端与服务端的数据交互通常使用JSON格式,然而,JSON... 目录问题背景1. 问题描述2. 错误分析解决方案1. 手动重新输入jsON2. 使用工具清理JSON3.

MySQL 设置AUTO_INCREMENT 无效的问题解决

《MySQL设置AUTO_INCREMENT无效的问题解决》本文主要介绍了MySQL设置AUTO_INCREMENT无效的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参... 目录快速设置mysql的auto_increment参数一、修改 AUTO_INCREMENT 的值。

关于跨域无效的问题及解决(java后端方案)

《关于跨域无效的问题及解决(java后端方案)》:本文主要介绍关于跨域无效的问题及解决(java后端方案),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录通用后端跨域方法1、@CrossOrigin 注解2、springboot2.0 实现WebMvcConfig

Go语言中泄漏缓冲区的问题解决

《Go语言中泄漏缓冲区的问题解决》缓冲区是一种常见的数据结构,常被用于在不同的并发单元之间传递数据,然而,若缓冲区使用不当,就可能引发泄漏缓冲区问题,本文就来介绍一下问题的解决,感兴趣的可以了解一下... 目录引言泄漏缓冲区的基本概念代码示例:泄漏缓冲区的产生项目场景:Web 服务器中的请求缓冲场景描述代码

Java死锁问题解决方案及示例详解

《Java死锁问题解决方案及示例详解》死锁是指两个或多个线程因争夺资源而相互等待,导致所有线程都无法继续执行的一种状态,本文给大家详细介绍了Java死锁问题解决方案详解及实践样例,需要的朋友可以参考下... 目录1、简述死锁的四个必要条件:2、死锁示例代码3、如何检测死锁?3.1 使用 jstack3.2

解决JSONField、JsonProperty不生效的问题

《解决JSONField、JsonProperty不生效的问题》:本文主要介绍解决JSONField、JsonProperty不生效的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录jsONField、JsonProperty不生效javascript问题排查总结JSONField

github打不开的问题分析及解决

《github打不开的问题分析及解决》:本文主要介绍github打不开的问题分析及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、找到github.com域名解析的ip地址二、找到github.global.ssl.fastly.net网址解析的ip地址三

MySQL版本问题导致项目无法启动问题的解决方案

《MySQL版本问题导致项目无法启动问题的解决方案》本文记录了一次因MySQL版本不一致导致项目启动失败的经历,详细解析了连接错误的原因,并提供了两种解决方案:调整连接字符串禁用SSL或统一MySQL... 目录本地项目启动报错报错原因:解决方案第一个:第二种:容器启动mysql的坑两种修改时区的方法:本地

springboot加载不到nacos配置中心的配置问题处理

《springboot加载不到nacos配置中心的配置问题处理》:本文主要介绍springboot加载不到nacos配置中心的配置问题处理,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录springboot加载不到nacos配置中心的配置两种可能Spring Boot 版本Nacos

Java中JSON格式反序列化为Map且保证存取顺序一致的问题

《Java中JSON格式反序列化为Map且保证存取顺序一致的问题》:本文主要介绍Java中JSON格式反序列化为Map且保证存取顺序一致的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未... 目录背景问题解决方法总结背景做项目涉及两个微服务之间传数据时,需要提供方将Map类型的数据序列化为co