I am trying to vertically center this “copy/paste”...
# compose
a
I am trying to vertically center this “copy/paste” icon in `ListItem`’s
trailingContent
slot, which is just
trailingContent: @Composable (() -> Unit)?
(not a Box / Column / Row scope). Anyone have idea?
s
What are the constraints that the slot takes in? If you do fillMaxSize() does it go from top to bottom so you can do wrapContentHeight on it then? Or does it just take up even more space that way?
a
Thanks, I saw this article https://blog.zachklipp.com/centering-in-compose/ and tried the
Modifier.fillMaxHeight().wrapContentHeight()
trick, that did nothing, changing it to
fillMaxSize().wrapContentSize()
made it take up most of the screen. I may have to write something custom
s
Yeah it depends on what ListItem does internally tbh. It sounds like it gives completely loose constraints to the trailing content so that it can take as much height as it needs, potentially expanding the entire card too. So with that, it may be hard to be able to ask it to just fill as much height as the items on the left were already taking. With a custom layout this would be quite easier to pull off, if you know you don't want that trailing content to even be bigger than the left content. Either a completely custom layout or a row of the left content and then the trailing content with intrinsicSize.max might be what you want. That's what I'd start with at least.