编辑文本“滞后";安卓 [英] Edittext "lag" android
问题描述
我第一次聚焦于edittext视图时,我发现要在文本框中写任何内容之前要等待一到两秒钟.
The first time i focus an edittext view i notice a lag of one or two seconds before i can write anything in the textbox.
即使在没有任何代码的应用程序上初始化应用程序,我也注意到这种行为.
I notice this behavior even on an app without any code more than what's nessecary to initialize the application.
我在做什么错了?
推荐答案
我已为我立即修复了此问题;我在DDMS中看到,输入文本时发生了许多重绘和重新计算,并且调用了许多有关RelativeLayouts的信息.因此,我检查了自己的布局;我有一些多行EditText,它们是RelativeLayout的直接子代.因此,我将它们包装成线性布局,然后在LinearLayout而不是每个EditText上指定所需的宽度/高度.
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)
之前:
<RelativeLayout>
<EditText
android:layout_width="wrap_content" />
<EditText
android:layout_width="wrap_content" />
</RelativeLayout>
之后:
<RelativeLayout>
<LinearLayout
android:layout_width="wrap_content" >
<EditText
android:layout_width="fill_parent" />
<EditText
android:layout_width="fill_parent" />
</LinearLayout>
</RelativeLayout>
将我的EditText包装到LinearLayout中,然后将动态布局控件放到LinearLayout中. 这是一个了不起的即时改进.
Wrapped my EditText's into a LinearLayout, and relinquished dynamic layout controls to the LinearLayout. It was an amazing and instant improvement.
这篇关于编辑文本“滞后";安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!