user1480821
user1480821

Reputation:

EditField in RelativeLayout has input lag

So I have a layout that is fairly simple and I have some weird interactions going on.

when i type on the "search_field" EditText the input works as expected. When I type in search_field2 field the input is randomly lagged and slow. Not every character is but its delayed enough to be unusable.

The only difference between the 2 editText fields is that the lagged one is nested in a relative layout. Does anyone know what could be causing it?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_margin="10sp"
>
    <EditText
        android:id="@+id/search_field"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:imeOptions="actionDone"
        android:background="#FFF"
        android:inputType="textPersonName"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
    >
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:id="@+id/search"
            android:src="@drawable/ico_search"/>
        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/search"
            android:text="Top recognized"/>
        <EditText
                    android:id="@+id/search_field2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_alignRight="@+id/title"
            android:ems="10"
            android:imeOptions="actionDone"
            android:background="#FFF"
            android:inputType="textPersonName"/>
    </RelativeLayout>
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/order"
    ></ListView>


</LinearLayout>

Upvotes: 1

Views: 665

Answers (1)

Habhome
Habhome

Reputation: 70

We had a similar issue in an application. Unfortunately we never found any solution other than avoiding RelativeLayout. It seems that is the culprit to this, I just don't know why. Our solution was to use LinearLayout instead and then place things a bit differently. Not optimal if you like RelativeLayouts, but in our case the Linear were not too hard to use.

Upvotes: 1

Related Questions