Reputation: 8331
I'm trying to override measureChild
in GridLayoutManager
to use specific layout params in measurement. But GridLayoutManager
has its own private implementation of measureChild
:
private void measureChild(View view, int otherDirParentSpecMode, boolean alreadyMeasured)
If I override public measureChild
in RecyclerView.LayoutManager
:
@Override
public void measureChild(View child, int widthUsed, int heightUsed) {
super.measureChild(child, widthUsed, heightUsed);
}
It will be never called.
Is it possible to measure children in GridLayoutManager
?
Upvotes: 1
Views: 817
Reputation: 1620
The 2 methods have different signatures so you shouldn't have any problems overriding them. Depending on the parameters you specify for the function in your child class the appropriate super will be called.
However, you need to modify your child class that extends from GridLayoutManager to override all functions that use GridLayoutmanager's implementation of measureChild
to be able use the other implementation.
To check which methods call measureChild
inside GridLayoutManager you can look at the source
EDIT: Seems like the layoutChunk
method derived from LinearLayoutManager is package private so in this case I suppose the only way is to extend RecyclerView.LayoutManager
and copy the entire code of GridLayoutManager replacing the measureChild
calls with your own replacement modifying the code appropriately
Upvotes: 0