remove additional underline in EditText

前端 未结 5 1100
广开言路
广开言路 2020-12-07 02:40

I have EditText with custom background drawable:

EditText code:



        
5条回答
  •  我在风中等你
    2020-12-07 03:32

    The underline text styling is applied by the BaseInputConnection of EditText to the text currently being "composed" using the styling applied by the theme attribute android:candidatesTextStyleSpans, which by default is set to the string candidates.

    The text part of the string is ignored, but the style spans are extracted from the string and applied to "composing" text which is the word the user is currently typing, a.o. to indicate that suggestions can be selected or that autocorrect is active.

    You can change that styling (e.g. to use bold or italics instead of underlines), or remove the styling altogether, by setting the theme attribute to a styled or unstyled string:

    
    
    
    
    
    

    Caveat: Removing all styling will cause the BaseInputConnection implementation to re-evaluate the theme attribute on every change of text, as the span information is lazy loaded and persisted only if the attribute is set to a styled string. You could alternatively set any other styling as is supported by Html:fromHtml(...), e.g. ... to the default text color, which makes no difference in display.

提交回复
热议问题