布局文件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. Pycharm中连接数据库乱码问题解决

    当我们使用pycharm建立数据库之后,看到里面的数据都是乱码,就像下面一样: 其实这个并不是pycharm的显示问题,而是建立数据库时产生的. 解决方法是到指定字符集的命令提示符中重新建表并指定字符 ...

  2. MSSQL镜像场景

    1.版本:一般MSSQL2016以下版本使用. 2.适用小数据库容量的异地备份:如果是数据库容量较大,产生的日志比较多:经测试,9G的数据库大小,镜像数月个日志大小达到400G,硬盘开销太大.

  3. Java开发环境之JDK

    查看更多Java开发环境配置,请点击<Java开发环境配置大全> 零章:JDK安装教程 1)下载JDK安装包 http://www.oracle.com/technetwork/java/ ...

  4. 异常详细信息: System.MissingMethodException: 无法创建抽象类。

    asp.net mvc 在使用post向后端传送json数据时报异常,在路由配置中添加如下即可 public static void RegisterRoutes(RouteCollection ro ...

  5. Oracle数据库插入过程中特殊符号

    -- 问题描述:(插入数据中有特殊符号)数据插入后乱码. -- 背景:客户提供部分Excel表格数据要求导入数据库.由于考虑到数据量不大所以粗略在Excel中进行了sql处理(在数据前后添加sql及对 ...

  6. maven学习笔记四(聚合和继承)

    聚合 现在假如,我创建了3个maven项目, user-core.2.user-log,3.user-service 这个时候,假如我们要打包这些项目,要一个一个来,会很麻烦.那么我们有没有更好的办法 ...

  7. Linux服务-bind

    目录 1.安装bind 2.配置bind 3.添加正.反向解析域 3.1 指向生效的配置文件 3.2 生成配置文件cljhfy.com.zone和163.168.192.zone 4.验证 Linux ...

  8. 第一次使用Git(常用的dos命令整理)

    在使用git的过程中,有许多dos命令也要会用才行 Git 工具分类 命令行 bash.cmd.power shell GUI Git GUI.GitHub Desktop IDE 集成 Visual ...

  9. Maven模块化搭建总结

    1.Maven插件在eclipse的安装 windows——>preferences——>Maven——>installations——>add——>installati ...

  10. LeetCode 449. Serialize and Deserialize BST

    原题链接在这里:https://leetcode.com/problems/serialize-and-deserialize-bst/description/ 题目: Serialization i ...