Android Ice Cream Sandwich Edittext: Disabling Spell Check and Word Wrap

Henry Thompson picture Henry Thompson · Jan 26, 2012 · Viewed 27.4k times · Source

Whilst testing on the Android Emulator running Android 4.0 (Ice Cream Sandwich), I have noticed that the Edittext does some quite strange things.

Firstly, it underlines every word identified as "misspelt" in red. How do I disable this? Secondly, although in the layout XML I have specified android:scrollHorizontally="true" word-wrap is enabled: how do I disable this as well? Here is the Layout XML code for the Edittext:

    <EditText
        android:id="@+id/editor"
        android:layout_width="40dp"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/toolbar"
        android:layout_toRightOf="@+id/toolbarleft"
        android:paddingBottom="0dp"
        android:paddingRight="0dp"
        android:scrollHorizontally="true"
        android:text=""
        android:inputType="textMultiLine" >
        
        <requestFocus />
    </Edittext>

Here is an example of the spell checker I need to disable:

Demonstration of Spell-Checker
(source: abstract-thoughts.com)

Thanks very much!

Answer

Henry Thompson picture Henry Thompson · Aug 19, 2012

Disabling Spell-Checking
In order to get rid of spell checking you must specify the EditText's InputType in the XML as the following:

android:inputType="textNoSuggestions"

However, my EditText needed also to be multiline, so I have added the following line to the EditText's XML:

android:inputType="textMultiLine|textNoSuggestions"

Disabling Word-Wrap
As noted, the XML attribute android:scrollHorizontally="true" does not work. However, strangely, if it is done through Java it does work. Here is the necessary code to achieve no word wrapping:

mEditText.setHorizontallyScrolling(true);