https://kotlinlang.org logo
#compose
Title
# compose
v

Vincent tiensi

03/24/2020, 4:44 AM
Heya! I’m having trouble wrapping my head around centering a view vertically in dev06. It looks like this and my code is like this…
Copy code
Row {
        // ...
        Container(width = 48.dp, height = 48.dp) {
            DrawVector(profilePlaceholderImage)
        }
        Spacer(modifier = LayoutPadding(start = 16.dp))
        Column {
          //  ...
          drawNameAndStars()
        }
// This line of code isn't working as expected 
        Container(width = 14.dp, height = 14.dp, modifier = LayoutFlexible(1f) + LayoutAlign.CenterRight) {
            DrawVector(arrowVector)
        }
    }
m

molikto

03/24/2020, 5:33 AM
LayoutGravity.Center is what you needed. I think the API is a bit confusing now
v

Vincent tiensi

03/24/2020, 5:33 AM
Thanks Minghao, I’ll give it a try
Looks like discoverability of
Modifiers
is about to change.
v

Vincent tiensi

03/24/2020, 5:36 AM
I see
z

Zach Klippenstein (he/him) [MOD]

03/24/2020, 2:38 PM
Also, have you seen the
ListItem
composable? I believe it gives you exactly this layout, you don't need to write it yourself.
v

Vincent tiensi

03/25/2020, 3:52 AM
^good to know, I’ll see if the material folder has stuff i can use