布局文件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. 【故障处理】ORA-12162 错误的处理

    [故障处理]ORA-12162: TNS:net service name is incorrectly specified 一.1  场景 今天拿到一个新的环境,可是执行sqlplus / as s ...

  2. C# DataTable 和List之间相互转换的方法(转载)

    来源:https://www.cnblogs.com/shiyh/p/7478241.html 一.List<T>/IEnumerable转换到DataTable/DataView 方法一 ...

  3. ovirt平台新建kvm操作

    登录后点击管理门户,随后计算-->虚拟机--> 新建 一般情况下需要操作的选项如下: 普通: 操作系统:linux 优化目标:服务器 描述:自定义 nic1:选择默认的网络 系统: 内存, ...

  4. python测试开发django-44.xadmin上传图片和文件

    前言 xadmin上传图片和上传文件功能 依赖环境 如果没安装Pillow的话,会有报错:practise.Upload.upload_image: (fields.E210) Cannot use ...

  5. 一些替代Xshell的软件推荐

    FinalShell: 面附上一些截图和官方连接: 官网:http://www.hostbuf.com/ FinalShell是一体化的的服务器,网络管理软件,不仅是ssh客户端,还是功能强大的开发, ...

  6. Linux必知必会--curl

    你有多自律,你就能走多远~ --久节奏.慢读书 Curl命令 学习每个linux命令都该掌握man命令.(可以使用man命令去查看每个命令的使用说明) curl命令是一个利用URL规则在命令行下工作的 ...

  7. spark 程序 windows 运行报错

    1 java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. at ...

  8. 记录第n次网站渗透经历

    如标题所示,第x次实战获取webshell的经历是非常美好且需要记录的(毕竟开始写博客了嘛).这能够证明这一路来的学习没有白费,也应用上了该用的知识. 首先怎么说呢,某天去补天看了看漏洞,发现有一个网 ...

  9. ThinkPHP的路由规则和URL生成,结合django的URL理解

    这个知识点,我觉得蛮重要的. 不作任何路由定义的TP,URL格式和controller之间,相当于强绑定. 路由配置,让URL和controller的关系可以自定义. URL生成,让controlle ...

  10. JAVA的概念理解:JavaSE、JavaEE、JavaME、jdk、jre、ide

    JavaSE是Java Standard Edtion的缩写,译成中文就是Java标准版,也是Java的核心.无论是 JavaEE(Java企业版)还是JavaME(Java微型版)都是以JavaSE ...