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 ...
随机推荐
- Keystore was tampered with, or password was incorrect
#修改key条目密码 # keytool -keypasswd -alias test.com -keypass oldkeypwd -new newkeypwd -storepass storepw ...
- Python入门篇-装饰器
Python入门篇-装饰器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.装饰器概述 装饰器(无参) 它是一个函数 函数作为它的形参 返回值也是一个函数 可以使用@functi ...
- python测试开发django-rest-framework-64.序列化(serializers.Serializer)
前言 REST framework中的serializers与Django的Form和ModelForm类非常像.我们提供了一个Serializer类,它为你提供了强大的通用方法来控制响应的输出, 以 ...
- Python库资源大全【收藏】
本文是一个精心设计的Python框架.库.软件和资源列表,是一个Awesome XXX系列的资源整理,由BigQuant整理加工而成,欢迎扩散.欢迎补充! 对机器学习.深度学习在量化投资中应用感兴趣的 ...
- Laravel —— 路由问题
在 Laravel 中,路由是项目的起点. 下面总结一些路由中常见的问题. 一.路由 404 是因为配置文件没有开启重定向模块,可以通过下面的操作解决. 1.php.ini 开启 openssl 模块 ...
- 《团队作业第三、四周》五阿哥小组Scrum 冲刺阶段---Day2
<团队作业第三.四周>五阿哥小组Scrum 冲刺阶段---Day2 一.项目燃尽图 二.项目进展 20182310周烔今日进展: 主要任务一览:完成总博客的提交,制定接下来的计划,编写博客 ...
- I2C 连接 12864 OLED 屏幕
http://ardui.co/archives/738 我是潘,曾经是个工程师.这是为 Ardui.Co 制作的 “Arduino 公开课” 系列的入门教程.上一课介绍了I2C 协议连接1602 L ...
- LeetCode 837. New 21 Game
原题链接在这里:https://leetcode.com/problems/new-21-game/ 题目: Alice plays the following game, loosely based ...
- 按值传递与按值引用详解(java版)
http://blog.csdn.net/zzp_403184692/article/details/8184751
- c++处理字符串string.find()与string::npos
1. string s = “xxx”; int a = s.find(‘x’); 如果没有匹配到,那么a = string::npos;