Hi. Is there a way to remove underline of the text (when writing) in BasicTextField? I tried this, b...
r
Hi. Is there a way to remove underline of the text (when writing) in BasicTextField? I tried this, but underline is still there:
Copy code
BasicTextField(
                    singleLine = true,
                    value = text,
                    textStyle = LocalTextStyle.current.copy(textDecoration = TextDecoration.None),
                    readOnly = readOnly,
                    onValueChange = {
                        onValueChanged(it)
                    }
                )
c
Are you referring to the bottom outline on the control? Or the text entered itself? Please provide a screenshot for reference
r
@Chris Sinco [G]: I mean under the text
c
Is removing it part of the design / requested by your UX designers?
r
Yes, it is part of the design. But if there is not easy way to do it, then it is better if i convince them to keep it this way.
c
I believe there is not an easy way to do it from the app level. And it would be a bad UX decision regardless to remove it since the underline is a platform level behavior that is expected for all text entry across all apps in Android. I’m not sure if your UX team is reacting to the fact that they don’t see this in iOS, but you can justify it from the UX perspective to say this is what Android users expect in apps, similar to how iOS has it’s own text selection / editing system-level UX.
c
@Chris Sinco [G] Having an underline doesn’t always make sense - lets say for example i’m entering a hashvalue which only takes in alphanumeric. When one doesn’t have to worry about supporting suggestions and conversions, this works against the ux. Here’s a very very simple example
The only way to work around this has been to using
Copy code
keyboardOptions = KeyboardOptions(
    capitalization = KeyboardCapitalization.None,
    autoCorrect = false,
    keyboardType = KeyboardType.Password,
    imeAction = ImeAction.Next
),
which makes the copied clipboard value being masked (as expected)
c
Sure, and those specific cases make sense. Though I’m not sure that is the reason for removing it by the OP.
c
Fair and maybe worth another thread altogether but this should be supported by the compose code. https://androidx.tech/artifacts/compose.ui/ui/1.2.0-alpha08-source/androidx/compose/ui/text/input/TextInputServiceAndroid.android.kt.html Somewhere in this class needs to be a
Copy code
if (!imeOptions.autoCorrect) {
            this.inputType = this.inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
        }
c
cc @Siyamed
s
I thought underline comes from composition but i might be wrong. We do not have 'suggestions' in the API yet, and should look into it. KeyboardType.Password might actually be the right option for an example such as hash. (Or an equivalent of do_not_learn since there is no value learning that value for IME) In terms of UX, how the text editing shows certain signals to user is an important part of platform and user education. Having different behaviors per app might actually confuse users and make editing hard. I suspect there is a balance between per app behavior and OS wide behavior.
c
I suspect there is a balance between per app behavior and OS wide behavior.
IMO, • don’t show underscore for suggestions similar to password entry • don’t have the clipboard show as bullet points (this might be a gboard thing out of your control)
1173 Views