Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText freezes/doesn't show text whilst typing

In my Android application I have an EditText which is sat inside a LinearLayout. This page is used in a ViewPager.

On majority of the devices I have tested on, it seems that the EditText behaves perfectly fine, except on a few.

It appears that on a few devices, when I touch the EditText and start typing, the text doesn't show but the suggestions do show. It is only after the Keyboard is closed that the text appears within the EditText.

Why is this the case? Why does the text not show whilst I type? Why does it show only after I close the keyboard?

Code:

<RadioGroup
    android:id="@+id/searchGroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginBottom="10dp">

...
...

<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="textCapWords|textPostalAddress"
        android:id="@+id/searchText"
        android:hint="@string/locationHint"
        android:imeOptions="actionDone"
        android:layout_below="@+id/locationGroup"
        android:layout_margin="10dp"
        android:singleLine="true"/>

...
...
</LinearLayout>

Update The EditText works fine if it's outside of the ViewPager`. It's only inside the ViewPager that it misbehaves.

like image 681
Subby Avatar asked Jul 23 '14 13:07

Subby


1 Answers

Having come across this issue at work with a number of devices and pulling my hair out (which I am sure you can appreciate) I found that wrapping the edittext view in a scrollview resolves the problem. The properties of the scrollview can be set so as not to affect the layout of your view.

Bounty me boy.

like image 74
Gapp Avatar answered Oct 20 '22 16:10

Gapp