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

Carl Benson

03/07/2023, 8:38 AM
Using
BasicTextField
to achieve text field without inner paddings, but then label animation is only happening on text entry, and not on focus (which it does on
TextField
). Is that expected?
z

Zach Klippenstein (he/him) [MOD]

03/07/2023, 4:59 PM
You’ve written the animation code yourself? Or copied it from material TF?
c

Carl Benson

03/08/2023, 7:44 AM
No, I haven't touched anything
Copy code
BasicTextField(
        value = value,
        onValueChange = onValueChange,
        modifier = modifier
            .indicatorLine(
                enabled = enabled,
                isError = isError,
                interactionSource = interactionSource,
                colors = TextFieldDefaults.textFieldColors(
                    focusedIndicatorColor = MaterialTheme.colors.onSurfaceVariant,
                ),
            ),
        enabled = enabled,
        readOnly = readOnly,
        textStyle = textStyle,
        keyboardOptions = keyboardOptions,
        keyboardActions = keyboardActions,
        singleLine = singleLine,
        maxLines = maxLines,
        visualTransformation = visualTransformation,
        onTextLayout = onTextLayout,
        cursorBrush = cursorBrush,
    ) { innerTextField ->
        TextFieldDefaults.TextFieldDecorationBox(
            value = value,
            innerTextField = innerTextField,
            enabled = enabled,
            singleLine = singleLine,
            visualTransformation = visualTransformation,
            interactionSource = interactionSource,
            isError = isError,
            label = label,
            placeholder = placeholder,
            leadingIcon = leadingIcon,
            trailingIcon = trailingIcon,
            colors = colors,
            contentPadding = contentPadding,
        )
    }
Do I have to copy the animation from TF? because to me it looks like the
TextFieldDecorationBox
should take care of that in
CommonDecorationBox
as you can see, on focus, the label is not animated as in TF
apologies for the incorrect icon for signin in with google 😂
15 Views