RecyclerView 自适应高度 正确做法。
来源:互联网 发布:单片机测量电池组电压 编辑:程序博客网 时间:2024/06/10 01:39
一个小小记录。
为了高度自适应,我找了许多方法。但是网上搜来搜去都只有两种方法
但是用到项目中 有不是很简单。
说说解决方法吧!
配置版本:compile 'com.android.support:recyclerview-v7:23.2.1'
遇过这个问题估计都知道
recyclerview 内容的高度不是 recyclerview 控制的 而是 LayoutManager 来设置的。
如果想要根据内容变化需要设置一个方法。
LayoutManager.setAutoMeasureEnabled(true);
如果大家有疑惑 其实可以看看 方法注释 有一句话这样写:
Defines whether the layout should be measured by the RecyclerView or the LayoutManager
* wants to handle the layout measurements itself.
我理解是 —让内容交给谁来控制
在看到 传递为 true的时候,交给谁
LayoutManager should call {@code setAutoMeasureEnabled(true)} to enable it. All of
* the framework LayoutManagers use {@code auto-measure}.
这个时候都有 LayoutManagers 来管理。
如果大家要设置动画的话,请看到这边。
https://developer.android.com/training/transitions/overview.html?utm_campaign=android_launch_supportlibrary23.2_022216&utm_source=anddev&utm_medium=blog
参考:
http://stackoverflow.com/questions/26649406/nested-recycler-view-height-doesnt-wrap-its-content/28510031#28510031
http://android-developers.blogspot.com/2016/02/android-support-library-232.html
- RecyclerView 自适应高度 正确做法。
- RecyclerView 自适应高度 正确做法
- RecyclerView的自适应高度
- RecyclerView自适应高度
- RecyclerView自适应高度
- 解决 RecyclerView 自适应高度
- RecyclerView 自适应高度
- RecyclerView高度随Item自适应
- RecyclerView高度随Item自适应
- RecyclerView自适应高度的LayoutManager
- RecyclerView自适应高度的LinearLayoutManager
- RecyclerView高度随Item自适应
- RecyclerView高度随Item自适应
- recyclerview高度根据条目自适应
- RecyclerView实现瀑布流,图片自适应高度
- recyclerView高度不能自适应(item满屏)
- android RecyclerView自适应高度的LayoutManager
- 要想在ie6,ie7和ff中都可以自适应高度,正确的做法是设置min-height和用cssHack设置height
- 图形数据库Neo4j(1)----简介及使用
- 统计学 Logistic Regression (逻辑回归)
- 将文字TextView的内容斜过来,应用例如:商品促销的标签
- 补码:统一加减运算
- PHP set_error_handler()函数的使用
- RecyclerView 自适应高度 正确做法。
- nginx虚拟主机别名配置
- 图形数据库 Neo4j(2) ----Java
- c语言学习笔记35之calloc
- 关于get和post
- nginx信息功能启用
- 约瑟夫环 Python&Swift实现
- 在你步入职业软件开发生涯那天起就该知道的五件事
- ADB无法找到Android设备