67 questions
193 votes
19 answers
281k views
Jetpack Compose - Column - Gravity center
I'm creating a layout with Jetpack Compose and there is a column. I would like center items inside this column: Column(modifier = ExpandedWidth) { Text(text = item.title) Text(text = ...
74 votes
6 answers
104k views
Weights in Jetpack compose
Is it possible to do weights in Jetpack Compose? For example, I'd like to set it up in such a way that one item is weighted as 1/3 of a layout, and the other takes up the remaining 2/3. In the XML/...
71 votes
6 answers
41k views
Create Vertical Divider Jetpack Compose
How to create vertical dividers with Jetpack Compose? I try to use Spacer and Box to do it, but it doesn't show up at all. Here is what i tried: Box( modifier = Modifier .fillMaxHeight() ...
56 votes
3 answers
38k views
How to make element fill the remaining space inside a Row or a Column in Jetpack Compose
I am trying to show two text messages besides each other in a row but when the size of the first text is big, the second view gets pushed out of the screen as shown below: The code: Row(modifier = ...
53 votes
1 answer
14k views
How to combine Arrangement.spacedBy() and Arrangement.Center in a Row.horizontalArrangement
Is it possible to combine Arrangement.spacedBy(16.dp) and Arrangement.Center in a Row.horizontalArrangement? What I would like to do is to center the content horizontally and also set a default ...
48 votes
6 answers
56k views
Kotlin Compose, Align items in row
I'm using the brand new Kotlin Compose for my view, I have a row with 2 items, how can I make them center-vertical-like? Row( modifier = Spacing(20.dp) ) { Text(text = &...
47 votes
1 answer
17k views
Fill height for child in Row
I try to achieve this layout but don't really know how: currently it looks like this: using this Code: @Preview(widthDp = 150) @Composable fun Item() { Card(shape = RoundedCornerShape(8.dp)) { ...
46 votes
4 answers
60k views
How to set Spacer between with two elements in a row
How to use Spacer filling between with two elements in a row, let one element at the start of row and another at the end? Row { Text("Start") Spacer(modifier = Modifier.SpaceBetween) ...
43 votes
5 answers
56k views
How align to bottom a row in Jetpack Compose?
I have a Column with some rows, and I want to align the last row at the botton, but this row is never located at the bottom of the screen, it stays right after the previous row: Column { //...
37 votes
1 answer
25k views
Jetpack Compose Fill remaining space in Row
I have a Row with max width, I want to place a Icon at start then a text and then another Icon at end. I have specific sizes of icon and I want the Text to fill up the remaining space. Row( ...
31 votes
5 answers
30k views
How to align Text to Top, Bottom and Center Vertically in Jetpack Compose?
How can I align the text using Text composable function vertically. Is there a way to do it without having to add another extra view to contain the Text. The textAlign parameter of Text only has the ...
28 votes
2 answers
21k views
Jetpack compose code to scroll down to the position of a specific UI element on clicking a Text
I am trying to scroll down to the position of a specific UI element on clicking a Text. The code for my Text is: Text( "What is autosaving?", ...
27 votes
4 answers
20k views
How to get the size of a Composable during runtime?
I have as an example the following Composable: @Composable fun CustomCanvas( ) { Box( Modifier .aspectRatio(1.33f) .fillMaxWidth()) } How do I know the size of this object ...
16 votes
1 answer
12k views
Horizontal Arrangement not working in Jetpack Compose Row
I follow the official document to learn about Rows. It's working fine. It arrange views horizontally and application runs without any issues. Problem: I want to set horizontalArrangement in Row. It ...
16 votes
1 answer
27k views
Align Box/Column to bottom of screen Jetpack Compose
I essentially want cards pinned to the top with a group of buttons pinned to the bottom (on screen keyboard) Using Column with a modifier like so only leads to the buttons covering the top cards: fun ...