disable "spell checking" on textView
Asked Answered
M

3

9

This is more a 'is there a more appropriate way' question as I have found a work around.

Some of my table headers are being picked up as spelling errors and underlined in red. Of course, that is not what I would like to see. I have found that using

android:inputType="textNoSuggestions"

does disable the spell check markings. I find it odd (bug?) that this is necessary as the docs state:

inputType: The type of data being placed in a text field, used to help an input method decide how to let the user enter text.

and there is no input associated with just textView. So is this the only/more appropriate way of avoiding the spell check and also, is this a bug that it is spell checking non-input fields?

UPDATE: per request this is sample xml

<TextView
        android:text="ID#"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:typeface="monospace"
        android:textSize="14sp"
        android:digits="4"
        android:textAlignment="gravity"
        android:layout_weight="5"
        android:gravity="left"
        android:singleLine="true"
        android:phoneNumber="true"
        android:inputType="textNoSuggestions|none">

</TextView>
Maurene answered 28/10, 2013 at 18:27 Comment(6)
Are you seeing this behavior on all devices, or only some?Twentytwo
Emulator.. haven't installed yet on a live device. Perhaps it is just an emulator issues?Maurene
If you have another device to try it with, I would. I can't recall ever seeing spell checking doing its thing on a TextView before.Twentytwo
I can confirm this happens even on a live device. Anything which would appear to trigger a spell check is underlined in red. setting the android:inputType="textNoSuggestions" removes this. This should not be even allowed on a field which does not take input in the first place.Maurene
Can you update your question with the full TextView definition from your layout XML?Twentytwo
@Tanis 7x: If on the device (or emulator) spell checking is enabled, ID# will cause a red error marking unless the textNoSuggestions is enabled.Maurene
T
4

First, I would try removing the android:digits, android:phoneNumber, and android:inputType attributes.

All of those are more intended for use with fields that allow input (such as EditTexts). It also doesn't look like you are using the android:digits attribute correctly, as the string you provide defines the only allowable characters.

In essence, this combination of attributes is telling Android that your TextView accepts input in the form of telephone numbers that contain only the number 4, that this TextView doesn't accept input of any type, and Android should not provide spellcheck suggestions.

If you are setting the content of the TextView yourself, there really is no reason to try to restrict the content of the TextView with flags such as android:phoneNumber since you are the one controlling that.

Twentytwo answered 2/11, 2013 at 19:54 Comment(2)
Good catch, not sure how those ended up in there as I have no phone numbers in the app at all - probably ticked a box accidentally in the layout designer in IDEA. </br> Looking further, it seems any item related to styling of an input field will trigger the spell check. I just tried one which had android:capitalize="characters" which is not part of the inputType group.Maurene
Removing android:inputType works for me. It was unnecessary in my casePatton
T
2

I know this is an old thread but removing the following from content XML worked for me:

    android:autoText="true"
Tessitura answered 31/1, 2016 at 19:19 Comment(0)
K
0

On later android studio versions try:

android:autoText="true"

inside of the (or any input) in the xml. On newer versions try:

android:inputType="textNoSuggestions"

Klemm answered 24/9, 2021 at 16:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.