Open zakgof opened 1 month ago
Hi, @zakgof!
Currently there is no official API to get actual number of cells when using Adaptive
. But I think SimpleGridCells
's Density.calculateCrossAxisCellSizes
method will be helpful.
This method is for internal but it is public interface method. So, you can use it as long as the interface is changed.
The method API looks like below,
fun Density.calculateCrossAxisCellSizes(availableSize: Int, spacing: Int): List<Int>
The availableSize
is the actual usable size of grid layout. And the spacing
is spacing size between cells. You can get spacing from Arrangement.spacing
property.
calculateCrossAxisCellSizes
returns list of size of each cells. The length of the list is the cell count.
For finding real usage, you can find rememberColumnCellWidthConstraints
or rememberRowCellHeightConstraints
from source.
When
SimpleGridCells.Adaptive
is used, is there any API to get the actual number of cells?