CymChad / CymChad/BaseRecyclerViewAdapterHelper
StateView的占用高度(宽度)似乎存在BUG
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 24.6k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
-
触发这个问题的需求是这样的,很简单。
RecyclerView的高度是包裹,而不是撑满布局。 -
使用的
占位View高度同样包裹或者一个不大的高度值。 -
本来想实现的效果是,无数据的时候,
ReclerView底部不会存在大量空白高度。 -
这时候关键点来了,我发现,当你使用
QuickAdapterHelper调用addBeforeAdapter添加Header时,每添加一个BeforeAdapter,ContentAdapter对应内容区域的高度就会增加一个BeforeAdapter的高度,直到撑满一个父布局。 -
简单来说就是
ContentAdapter对应内容区域会自动变高直到撑满他能撑满的布局高度。造成的问题,1,就算RecyclerView的高度没有达到父布局高度,按照常理RecyclerView应该是无法进行滑动的,但是因为ContentAdapter对应内容区域的高度大于占位View的高度,所以RecyclerView竟然可以滑动。2,就算RecyclerView高度达到了父布局高度,同样因为此时ContentAdapter对应内容区域的高度也变成了父布局的高度,那么RecyclerView下方会滑动出来大量的空白,说白了,这时候ContentAdapter对应内容区域的高度已经不是占位View的高度了,变成了HeaderView总高度+占位View的高度,直到占满父布局,我认为这是个BUG。 -
ContentAdapter对应内容区域的高度应该永远和要显示的占位View高度保持一致不是么???只要不添加Header,ContentAdapter对应内容区域确实可以保证他跟占位View的高度是一致的。但是只要添加了Header,ContentAdapter对应内容区域的高度就会开始变高,这真的不太对吧? -
使用的是4.1.4版本,可以用demo比较容易的重现此问题。如需要我可以上传github提供
-
就如上面2个图简单演示,
RecyclerView内容高度本应该是图1的高度,实际也是,但是就像图2,它内部的滑动区域的高度却无端的高了一个Header的高度。这真的就是个BUG吧?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in the 4.1.4 demo, then inspect QuickAdapterHelper.addBeforeAdapter and how the ContentAdapter measures its content area. Compare behavior with and without a Header and with a wrapped-height RecyclerView. Done means the content area stays equal to the placeholder View height and no extra blank scroll region appears.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100