Pre-Measuring a RecyclerView
I have a Custom View that inherits from RecyclerView. Once created, the RecyclerView will always have the same number of items, all of which will remain the same size once created. All other items on the page will remain the same size as well (except of course if the user rotates their phone). I want the RecyclerView to use whatever space the user specifies when using the View in their layout (whether it be a fixed size, match_parent, or something like layout_weight). All the items will be the same size (which I will calculate during initialization to make each item using rvwidth/itemcount) so that the total is the available width. However, because layout involves multiple passes, the width is not available during the initial layout in methods such as OnCreateViewHolder
& OnBindViewHolder
. What should I do to be able to get the available space when creating & binding my RecyclerView?