布局文件1

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sv_home_hm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="none"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_home_model_type"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_marginTop="16dp"></androidx.recyclerview.widget.RecyclerView> <androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"></androidx.recyclerview.widget.RecyclerView> </LinearLayout> </ScrollView>

如图,公司项目有一个界面要用到2个RecyclerView来实现,由上至下垂直排列;

我的布局是自定义ScrollerView套LinearLayout套的RecyclerView;

调试接口的时候,发现第三个RecyclerView的展示有问题,就是我们说的显示不全;

接口明明返回很多数据的,我尝试过很多方法都不行,没有达到想要的结果;

后来我的解决方案是把RecyclerView外层嵌套的线性布局(LinearLayout)换成相对布局(RelativeLayout),就好了,如下:

这是垂直冲突的原因

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sv_home_hm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">  <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_home_model_type"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_marginTop="16dp"></androidx.recyclerview.widget.RecyclerView> <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_home_model_recommend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"></androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</ScrollView>

android -------- 解决RecyclerView显示不全只显示一条item的问题的更多相关文章

  1. EF 外键不显示、如何让外键显示!增、删、改 操作时,外键不显示,只显示导航属性!

    一.问题描述:EF 外键不显示.如何让外键显示!增.删.改 操作时,外键不显示,只显示导航属性! EF 添加.增加.插入数据时,外键不显示! 二.解决方案:在根据数据库生成模型的时候,选中“在模型中” ...

  2. Android解决RecyclerView中的item显示不全方案

    最近的项目中实现订单确定页面.需要使用ScrollView嵌套RecyclerView,当RecyclerView中的item数量比较多时,就会出现item只显示一部分数据,并没有将用户勾选的商品数量 ...

  3. ppt图片在word中不能正常显示,只显示为矩形框的解决方法

    word中插入的其他图片是好的,但是从ppt复制粘贴过来的图片只显示个框. 解决方法:以下红框中内容去选中.

  4. 解决lScrollView嵌套ListView只显示一行的问题,listvie显示全部的item

    ScrollView嵌套ListView只显示一行的问题 1.思路:给listview重新添加一个高度. listview的高度==listview.item的高度之和. 2.注意:关键是添加list ...

  5. 解决ListView在界面只显示一个item

    ListView只显示一条都是scrollview嵌套listView造成的,将listView的高度设置为固定高度之后,三个条目虽然都完全显示.但是这个地方是动态显示的,不能写死.故采用遍历各个子条 ...

  6. 关于Resouces.resx 在WPF中{x:Static}不显示内容只显示字段的问题解决办法

    问题现象:<object property="{x:Static prefix:typeName.staticMemberName}" .../> 界面中只显示资源引用 ...

  7. Android 嵌套GridView,ListView只显示一行的解决办法

    重写ListView.GridView即可: public class MyListView extends ListView { public MyListView(Context context) ...

  8. 【Android】我有放入Icon到mipmap,但不显示,只显示安卓机器人Icon(Android 8.0 图标适配)

    首先,放上别人写的博客,而我自己的博客,只会写大概思路,给自己留给备忘 https://blog.csdn.net/guolin_blog/article/details/79417483 其实会发生 ...

  9. Android 自定义Adapter 但listview 只显示第一条数据

    <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content ...

随机推荐

  1. HBase集群环境搭建v2.0

    本文档环境基于ubuntu16.04版本,如果最终不使用SuperMap iServer 10i ,可以不配置geomesa-hbase_2.11-2.2.0-bin.tar.gz 相比1.0版本,升 ...

  2. node.js 学习一

    Node.js 是单进程单线程应用程序,但是通过事件和回调支持并发,所以性能非常高. 与PHP 相似 都是单进程. Node.js 的每一个 API 都是异步的,并作为一个独立线程运行,使用异步函数调 ...

  3. Linux DNS 主从复制

    设置主从DNS的主要是为了冗余,分担压力,防止服务器宕机后,DNS无法正常解析. 配置 master 正常配置DNS服务. 设置主机名 [root@localhost ~]# hostnamectl ...

  4. Thinkphp 配置不用输入index.php

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/u011186019/article/det ...

  5. python基础---python环境搭建windows版

    Python3.7.1标准安装 1.官网下载 官网地址:https://www.python.org/downloads/ 下载3.7.1 下载64/32bitwindows安装文件,下图x86-64 ...

  6. linux的后台运行相关命令

    screen -S name 创建一个名为name的后台,或者说bash面板,在这上面运行的任务不会因为连接断开而退出,且保留bash上的信息 screen -ls 列出所有的screen scree ...

  7. 使用Apache commons-maths3-3.6.1.jar包,在hive上执行获取最大值的操作

    udf是对hive上的每行(单行)数据操作,现在我要实现对hive上的一列数据操作,udf函数已经满足不了我的要求了,使用udaf对hive的一列求最大值: 代码如下: package com; im ...

  8. python写入excel(方式二待完善)

    import xlsxwriter #创建一个工作簿并添加一张工作表,当然工作表是可以命名的# workbook = xlsxwriter.Workbook('Expenses01.xlsx')# w ...

  9. 极限挑战----3小时完成OA系统(失败)

    今天老师要求三小时把OA系统做出了,之前一点也没接触过,对其不了解,而且这几天一直把时间放在六级了,对Web重视有点少. 最终我只做了登录和校验,可以显示富文本框,但不能提交数据库. 总之还有还多没有 ...

  10. (尚023)Vue_案例_交互添加

    最终达到效果: 1.做交互,首先需要确定操作哪个组件? 提交------操作组件Add.vue 2.从哪开始做起呢? 从绑定事件监听开始做起,确定你跟谁绑定事件监听,在回调函数中做什么, ====== ...