Get height for RecyclerView child views at runtime

后端 未结 2 2032
闹比i
闹比i 2021-01-06 13:57

I\'m trying to make an expandable TextView that expands/collapses when a user presses a button. The TextView and ImageButton are in a CardView, which is added to a RecyclerV

2条回答
  •  不知归路
    2021-01-06 14:33

    You can override onLayoutChildren in the LayoutManager and measure it if state.isPreLayout return false. I'm hoping that you are not changing the total size of the View because LayoutManager will not see this change. Also because layout requests are disabled at that stage, your view will not get a new measure and layout.

    If it resizes your view, do it in onBind and measure the textview yourself to decide whether you want to enable the button or not.

提交回复
热议问题