EditText lagging with time - Android

508 views Asked by At

I create app with SpannableString (BackgroundColorSpan, ForegroundColorSpan and StyleSpan). First time EditText work fine, but after 10-15 minutes, the EditText starts to freeze. I use profiler to see why input slow down (photo below)I think that reflow method slow down input

    <ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fillViewport="true"
            android:scrollbars="none">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <EditText
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:minLines="1"
                    android:paddingLeft="5dp"
                    android:paddingTop="11dp"
                    android:paddingRight="70dp"
                    android:paddingBottom="90dp"
                    android:gravity="top|start"
                    android:scrollHorizontally="false"
                    android:background="@android:color/transparent"
                    android:maxLength="999999"
                    android:maxLines="999999"
                    android:inputType="textMultiLine|textVisiblePassword|textNoSuggestions"
                    android:textSize="14dp" />
            </LinearLayout>
    </ScrollView>

ScrollView inside fragment. How can I solve this problem?

2

There are 2 answers

2
S. Banovic On

I had similar problem and my solution was to delete: android:textAllCaps="true"

0
Harsh Modani On

I think you should decrease the android:maxLength and android:maxLines attributes in the xml file. These are very large values and can cause significant lag. Also, if this does not work alone, you should share your Java/Kotlin file as the problem may lie there.