EditText freezes/doesn't show text whilst typing

孤人 提交于 2019-12-06 03:42:49

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/24912022/edittext-freezes-doesnt-show-text-whilst-typing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!