android -------- 解决RecyclerView显示不全只显示一条item的问题
布局文件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的问题的更多相关文章
- EF 外键不显示、如何让外键显示!增、删、改 操作时,外键不显示,只显示导航属性!
一.问题描述:EF 外键不显示.如何让外键显示!增.删.改 操作时,外键不显示,只显示导航属性! EF 添加.增加.插入数据时,外键不显示! 二.解决方案:在根据数据库生成模型的时候,选中“在模型中” ...
- Android解决RecyclerView中的item显示不全方案
最近的项目中实现订单确定页面.需要使用ScrollView嵌套RecyclerView,当RecyclerView中的item数量比较多时,就会出现item只显示一部分数据,并没有将用户勾选的商品数量 ...
- ppt图片在word中不能正常显示,只显示为矩形框的解决方法
word中插入的其他图片是好的,但是从ppt复制粘贴过来的图片只显示个框. 解决方法:以下红框中内容去选中.
- 解决lScrollView嵌套ListView只显示一行的问题,listvie显示全部的item
ScrollView嵌套ListView只显示一行的问题 1.思路:给listview重新添加一个高度. listview的高度==listview.item的高度之和. 2.注意:关键是添加list ...
- 解决ListView在界面只显示一个item
ListView只显示一条都是scrollview嵌套listView造成的,将listView的高度设置为固定高度之后,三个条目虽然都完全显示.但是这个地方是动态显示的,不能写死.故采用遍历各个子条 ...
- 关于Resouces.resx 在WPF中{x:Static}不显示内容只显示字段的问题解决办法
问题现象:<object property="{x:Static prefix:typeName.staticMemberName}" .../> 界面中只显示资源引用 ...
- Android 嵌套GridView,ListView只显示一行的解决办法
重写ListView.GridView即可: public class MyListView extends ListView { public MyListView(Context context) ...
- 【Android】我有放入Icon到mipmap,但不显示,只显示安卓机器人Icon(Android 8.0 图标适配)
首先,放上别人写的博客,而我自己的博客,只会写大概思路,给自己留给备忘 https://blog.csdn.net/guolin_blog/article/details/79417483 其实会发生 ...
- Android 自定义Adapter 但listview 只显示第一条数据
<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content ...
随机推荐
- day 05 预科
目录 文本处理 什么是文件 什么是文本 视频/音频文件(多媒体文件) 我们如何通过文本编辑器去控制txt文件 文本高级 文本处理+高级分析 文本处理 什么是文件 文件是操作系统提供的一个特殊概念,拿来 ...
- Ubuntu 开发环境搭建
一.修改权限 Ubuntu 用户权限相关命令 - 彭浪 - 博客园 Ubuntu 文件文件夹查看权限和设置权限 - 朝阳的向日葵 - 博客园 二.安装简体中文支持 三.安装搜狗输入法 四.安装Goog ...
- 一小部分用python进行MD5加密的小技巧
上个图 要求计算出开头为ae3da且盐值为3c6e的字符串 简单的思路就是直接进行枚举,然后筛选符合条件的MD5加密字符,代码如下 #-*- coding:utf- -*- import hashli ...
- C++学习(2)—— 数据类型
C++规定在创建一个变量或者常量的时候,必须指定出相应的数据类型,否则无法给变量分配内存 数据类型存在意义:给变量分配合适的内存空间 1. 整型 作用:整型变量表示的是整数类型的数据 C++中能够表示 ...
- 矩阵迹tr(AA*)的计算公式证明
与tr(AB)=tr(BA)的证明思路相同,均使用矩阵的元素表示形式进行证明.
- Collaborative Knowledge base Embedding (CKE)
Collaborative Knowledge base Embedding (CKE) 在推荐系统中存在着很多与知识图谱相关的信息,以电影推荐为例: 结构化知识(structural knowled ...
- The Sum of the k-th Powers(Educational Codeforces Round 7F+拉格朗日插值法)
题目链接 传送门 题面 题意 给你\(n,k\),要你求\(\sum\limits_{i=1}^{n}i^k\)的值. 思路 根据数学知识或者说题目提示可知\(\sum\limits_{i=1}^{n ...
- git上传者姓名修改
只需要两个指令 git config user.name 和 git config –global user.name 在控制台中输入git config user.name获取当前的操作名称 修改名 ...
- .pdb 文件的内部结构
粗略察看一 下.pdb 文件,会发现在其起始位置存放的是这样一个字符串“Microsoft C/C++ program database 2.00”.可以看出 PDB 是 Program Databa ...
- Poj 2411 Mondriaan's Dream(状压DP)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Description Squares and rectangles fascina ...