Edittext “lag” android

醉酒当歌 提交于 2019-12-06 10:44:30

I've INSTANTLY fixed this issue for me; I saw in the DDMS that a lot of redraw's and recalculations were occurring while entering text, and a lot of info about RelativeLayouts were being called. So, I checked my layout; i had some Multi-Line EditText's who were direct children of a RelativeLayout. So, I wrapped those up into a Linear Layout, and specified my desired width/height at the LinearLayout, not each EditText.

Guess what? It totally fixed it!!

(below, some code... keep in mind, this is just an approximation. Don't try and copy/paste)

BEFORE:

<RelativeLayout>
    <EditText
        android:layout_width="wrap_content" />
    <EditText
        android:layout_width="wrap_content" />
</RelativeLayout>

AFTER:

<RelativeLayout>
    <LinearLayout
        android:layout_width="wrap_content" >
        <EditText
            android:layout_width="fill_parent" />
        <EditText
            android:layout_width="fill_parent" />
    </LinearLayout>
</RelativeLayout>

Wrapped my EditText's into a LinearLayout, and relinquished dynamic layout controls to the LinearLayout. It was an amazing and instant improvement.

Are you using the emulator?

This is common when you are using the emulator regardless of debug mode or not...at least from my (limited) experience so far. Try your app out on a real phone and see what happens.

I turned off USB debugging and uninstalled a few keyboards. Seems to work fine now. Thanks all.

jaksnon

Edit AndroidManifest:

My old code

< uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />

My new code

< uses-sdk android:minSdkVersion="8" />

I just removed the targetSdkVersion and the lag went away.

In my case the symptoms were the same, a delay occurred to present the keyboard and when typing the letters were gradually appearing. The solution is because I had put a Background image in the RelativeLayout, when I did a test taking the background worked out and stopped the delay, so I entered an online site that reduces photos and then reduced from 93kb to 50kb and worked perfectly.

In my case the problem was the background-drawable for the activity (as dialog) on XML, it was too heavy. changing it, works fine.

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