How can I align a `Text` to the start of the `Text...
# compose
g
How can I align a
Text
to the start of the
Text
as label in a
TextField
?
Copy code
@Composable
fun SomeTextField(
    label: String,
) {

    TextField(
        label = {
            Text( // text label here
                text = label
            )
        }
    )

    Text("Here is an error text") // align this to start where the text label starts
}
🤔
l
I'm really not sure it would work but with a ConstraintLayout maybe? I'm not sure you can add constraints to composables not directly in the layout (like label here) but it's worth investigating
g
Right, I'll try!
c
When I'm back at my desk I can check how I did this from the samples.
🙏 1
I think I copied my implementation based on one of these samples here. You can pretty much copy pasta this entire thing into your project and play around with all of the text field samples: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]samples/TextFieldSamples.kt?q=compose%20sample%20text%20field
c
The padding of TextField is specific to the Material Design spec, so aligning perfectly will have to be done through manually nudging Text
💯 1
g
Yeah that's what I thought, thanks to you two @Colton Idle @Chris Sinco [G] 💙
👍 1