Questions tagged [android-jetpack-compose-layout]
62 questions
                    
                    142
                    
            votes
                
                18 answers
            
        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 = item.description)
 }
         
    
    
        mac229
        
- 4,319
- 5
- 18
- 24
                    62
                    
            votes
                
                7 answers
            
        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/ViewGroup style, you can achieve this using…
         
    
    
        Corey Waldon
        
- 621
- 1
- 5
- 3
                    46
                    
            votes
                
                3 answers
            
        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()
        .width(2.dp)
        .background(color =…
         
    
    
        wiryadev
        
- 1,089
- 1
- 11
- 33
                    43
                    
            votes
                
                3 answers
            
        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 = Modifier.fillMaxWidth()) {
    Text(
        text =…
         
    
    
        David Ibrahim
        
- 2,777
- 4
- 17
- 41
                    35
                    
            votes
                
                1 answer
            
        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)) {
        Row {
           …
         
    
    
        JacobZ
        
- 379
- 3
- 8
                    31
                    
            votes
                
                5 answers
            
        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 = "Hello $name!")
        Spacing(10.dp)
       …
         
    
    
        Alireza Akbari
        
- 2,153
- 2
- 28
- 53
                    28
                    
            votes
                
                5 answers
            
        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 following…
         
    
    
        danartillaga
        
- 1,349
- 1
- 8
- 19
                    27
                    
            votes
                
                3 answers
            
        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 {
        // RED BOX
        Row(
            modifier =…
         
    
    
        Paul9999
        
- 751
- 1
- 11
- 26
                    25
                    
            votes
                
                3 answers
            
        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)  // How to set the modifier
    Text("End")
}
         
    
    
        ccd
        
- 5,788
- 10
- 46
- 96
                    23
                    
            votes
                
                1 answer
            
        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 spacing of 16.dp.
I know that I can combine the Row and…
         
    
    
        Roberto Leinardi
        
- 10,641
- 6
- 65
- 69
                    23
                    
            votes
                
                1 answer
            
        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(
   Modifier
   .fillMaxWidth()
   .height(30.dp)
){
 …
         
    
    
        DelusionaL
        
- 745
- 2
- 6
- 15
                    20
                    
            votes
                
                2 answers
            
        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?",
                color = colorResource(id = R.color.text_highlight),
       …
         
    
    
        Sparsh Dutta
        
- 2,450
- 4
- 27
- 54
                    19
                    
            votes
                
                3 answers
            
        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 after composition?
Why I want to know:
I'm trying…
         
    
    
        user3872620
        
- 1,036
- 10
- 12
                    14
                    
            votes
                
                1 answer
            
        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 didn't arrange it.
My code:
@Composable
fun…
         
    
    
        Ranjithkumar
        
- 16,071
- 12
- 120
- 159
                    10
                    
            votes
                
                1 answer
            
        Cannot find a way to use both at same time, bottom sheet and bottom navigation bar in android compose
In android compose, there is Scaffold composable function to create a layout that contains bottom navigation bar and there is another function named BottomSheetScaffold to create a layout that contains bottom navigation bar.
 My question is how to…
         
    
    
        David Ibrahim
        
- 2,777
- 4
- 17
- 41