0.21.0
I've been using litho for a while now.
But there is a task of implementing a scrollable list in bottomsheetdialogfragment.
By setting the section, the height of my LithoView is 0.
Please tell me how to solve this problem?
PS
Everything is fine if you display the item immediately, or rigidly set the height for LithoView in xml
val c = SectionContext(litho_view.componentContext)
val listRecyclerConfiguration = ListRecyclerConfiguration.create()
.orientation(LinearLayoutManager.VERTICAL)
.build()
litho_view.setComponent(
RecyclerCollectionComponent.create(c)
.disablePTR(true)
.clipToPadding(false)
.nestedScrollingEnabled(false)
.overScrollMode(View.OVER_SCROLL_NEVER)
.recyclerConfiguration(listRecyclerConfiguration)
.section(
createList(c, list)
).build()
)
``
private fun createList(
c: SectionContext, list: List<TestObject>
): TestSection.Builder {
return section(c, TestSection::create) {
list(list)
}
}
I think you need to enable canMeasureRecycler(true) when creating RecyclerCollectionComponent, and the height would be calculated when the data is given for the first time.
RecyclerCollectionComponent.create(c)
...
.canMeasureRecycler(true)
.build()
@topwu or @colriot
canMeasureRecycler(true) makes it possible to display the list.
but this sets the section to the entire available height.
Please tell me how to display my list with the height of the content.
To allow the height to be adjustable by content, you would need to enable .wrapContent(true) in RecyclerBinderConfiguration:
val configuration =
RecyclerBinderConfiguration.create()
.isReconciliationEnabled(false)
.wrapContent(true)
.build()
val listRecyclerConfiguration =
ListRecyclerConfiguration.create()
.recyclerBinderConfiguration(configuration)
.build()
val component =
RecyclerCollectionComponent.create(c)
.recyclerConfiguration(listRecyclerConfiguration)
.build()
its works!!!
Thank you very much)))
Most helpful comment
I think you need to enable
canMeasureRecycler(true)when creating RecyclerCollectionComponent, and the height would be calculated when the data is given for the first time.