Alexander Maryanovsky
06/03/2026, 4:12 PMGrid layout, doesn’t
repeat(3) {
column(1.fr)
}
mean that each column will have identical width (assuming all content fits)?Alexander Maryanovsky
06/03/2026, 4:16 PMAlexander Maryanovsky
06/03/2026, 4:17 PMAlexander Maryanovsky
06/03/2026, 4:42 PMChrimaeon
06/03/2026, 4:48 PMScan Resolution - this one is bigger than 1/3. so the grid uses up the space for its “required” size and the first 2 columns get the rest to fill both of their 1fr’s. The first 2 have the same width, right?Alexander Maryanovsky
06/03/2026, 4:52 PMAlexander Maryanovsky
06/03/2026, 4:53 PMAlexander Maryanovsky
06/03/2026, 4:54 PMAlexander Maryanovsky
06/03/2026, 4:54 PMChrimaeon
06/03/2026, 4:56 PMText?Alexander Maryanovsky
06/03/2026, 4:56 PMColumn with two `Text`sAlexander Maryanovsky
06/03/2026, 4:56 PMAlexander Maryanovsky
06/03/2026, 4:58 PMChrimaeon
06/03/2026, 4:58 PMChrimaeon
06/03/2026, 5:01 PMColumn? on the Google examples they use fillMaxSize on their “items”.
https://github.com/android/snippets/blob/bbca97b6d9c068af9c406ad3e7f14dc2640735ed/compose/snippets/src/main/java/com/example/compose/snippets/layouts/grid/Cards.ktAlexander Maryanovsky
06/03/2026, 5:07 PM@OptIn(ExperimentalGridApi::class)
@Composable
fun App() {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Grid(
config = {
repeat(3) {
column(1.fr)
}
},
Modifier.fillMaxWidth()
) {
Cell("Short")
Cell("MediumLength")
Cell("Supercalifragilisticexpialidocious")
}
}
}
@OptIn(ExperimentalGridApi::class)
@Composable
fun GridScope.Cell(text: String) {
Text(
text = text,
textAlign = TextAlign.Center,
modifier = Modifier
.gridItem(alignment = Alignment.Center)
.fillMaxSize()
.border(1.dp, Color.Black)
)
}Alexander Maryanovsky
06/03/2026, 5:08 PMAlexander Maryanovsky
06/03/2026, 5:08 PMAlexander Maryanovsky
06/03/2026, 5:10 PMAlexander Maryanovsky
06/03/2026, 5:11 PMAlexander Maryanovsky
06/03/2026, 5:13 PMAlexander Maryanovsky
06/03/2026, 5:13 PMAlexander Maryanovsky
06/03/2026, 5:14 PMChrimaeon
06/03/2026, 5:15 PMgridItem(alignment = Alignment.Center)Alexander Maryanovsky
06/03/2026, 5:16 PMtiwiz
06/03/2026, 7:53 PM.3.f rather than 1.fr? fr is the remaining space after the other elements are calculated (from the documentation Flexible (Fr): Distributes remaining space proportionally after fixed and percentage tracks are calculated. For example, if two rows are set to 1.fr and 3.fr, the latter receives 75% of the remaining height. - https://developer.android.com/develop/ui/compose/layouts/adaptive/grid/container-properties)
If you want them equal, the easiest way is to use the Percentage approachAlexander Maryanovsky
06/03/2026, 7:55 PM<http://0.33.fr|0.33.fr>tiwiz
06/03/2026, 7:56 PM.3.f and .3.fr. the final R is what changes the behaviortiwiz
06/03/2026, 7:57 PMr it should divide the space evenly.tiwiz
06/03/2026, 8:00 PM1.fr will do in this way: the first one will calculate its size and take all of it, let's say 30% of all the available space because it's short. The second's 1.fr will be calculated against the remaining of the space (100-30-> 70%). And so on. the .fr calculate the remaining space after the others before get their sizestiwiz
06/03/2026, 8:00 PMr, that will use the percentageAlexander Maryanovsky
06/03/2026, 8:01 PMtiwiz
06/03/2026, 8:03 PMAlexander Maryanovsky
06/03/2026, 8:03 PMAlexander Maryanovsky
06/03/2026, 8:05 PMthe first one will calculate its size and take all of it, let’s say 30% of all the available space because it’s short.That doesn’t seem right. Why would it take 30%?
Alexander Maryanovsky
06/03/2026, 8:06 PMAlexander Maryanovsky
06/03/2026, 8:09 PMfr ones, each receiving space proportional to its value. Basically like weight in a row.Alexander Maryanovsky
06/03/2026, 8:11 PMAlexander Maryanovsky
06/03/2026, 8:11 PM<http://2.fr|2.fr> should receive twice the width than a <http://1.fr|1.fr> item. Two <http://1.fr|1.fr> items should receive the same width.Alexander Maryanovsky
06/03/2026, 8:16 PMKyant
06/04/2026, 3:00 AMcolumn(1f / 3f) for equal widths