If I have a column with alignment set to center. I...
# compose
c
If I have a column with alignment set to center. Is there a way for an item in the column to opt out of this? I want everything in my column to be centered except one item. Thoughts?
Copy code
Column(
    horizontalAlignment = Alignment.CenterHorizontally,
a
Wrap it with a Box, or Column and set align on that wrapper
c
Alright. I was hoping there'd be another solution besides adding another wrapper layout composable, but so be it!
a
You can set alignment on the child using
Modifier.align()
. It's in
ColumnScope
.
1
c
Ooh. Didn't think it'd override. Let me give it a whirl.
c
Yes, the
Modifier.align
is your friend in the context of Box/Column/Row (scope).
(The last paragraph of text isn’t “aligned” because text align is different from
Modifier.align
🙂)
c
Ah. Thanks @Chris Sinco [G]
a
@Chris Sinco [G] Love the tool. Wish knew about it before. Where is it listed as a Jetpack Compose tool?
c
It’s not an official Compose tool at the moment - it’s a personal plugin I built to try out Compose Desktop but also try to make learning Modifiers easier/faster/more fun https://plugins.jetbrains.com/plugin/16417-compose-modifiers-playground
mind blown 3
But we (Android Studio Design Tools team) have discussed how we could incorporate it back into the official toolchain. The technical challenge right now though is compilation speed since it takes seconds to refresh the Preview as you add/remove/modify Modifiers.
My plugin is Compose rendering Compose, with a lot of assumptions about the generated code to render, which is why the experience is much faster than Preview in Android Studio. That is, there’s no compilation.
🆒 3
a
Teaching Compose and SwiftUI to designers . This tool will be very helpful 🙏🏽
👍 1
c
Good to know, as I’m a designer myself!
At some point, it’d be nice to have this as a standalone desktop app or when ready, a Compose for Web app!
👍🏽 1
👍 1