I am currently having a problem measuring recyclerView before it appears. I need a measured value to start the "expand" animation.
This was done earlier for the gridView in the code I'm working on, and I'm trying to port it to RecyclerView using the GridLayoutManager
final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); final int heightSpec = View.MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, View.MeasureSpec.AT_MOST); mGridView.measure(widthSpec, heightSpec); int targetHeight = mGridView.getMeasuredHeight();
It worked with gridView, but if I call a measurement method with the same measurement parameters in recyclerView, the result is always 16777215, which I think may be the maximum value for something, but I can’t say that.
I saw a message explaining that a view can be measured before it is displayed on the screen by measuring it using the following measurement parameters:
final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); final int heightSpec = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
but I get 0 for recyclerView.getMeasuredHeight () ;.
Is there a way to correctly measure the height of a recyclerView before it is displayed on the screen?
Thanks.
android android-view android-recyclerview android-viewgroup
Loïc
source share