我面临一个非常有趣但令人讨厌的错误,在我的线性布局中,我使用负边距隐藏了另一个线性布局,当用户从列表中选择一种类型时,我使用平移动画将布局置于前面,错误是布局来到前面有一个编辑文本,它变得死了,当我滚动时(我的主要布局被滚动视图包围)它变得活跃,当我停止滚动时它又变得死了......我真的无法判断为什么会发生这种情况,所以伙计们请帮忙....
I am facing a quite interesting but annoying error, in my linear layout i have hided another linear layout using margin in negative and when user selects a type from a list i bring layout to front using Translational Animation the error is that the layout comes to front have an edit text which becomes dead and when i scroll (my main layout is surrounded by scroll view) it comes alive and when i stop scrolling it becomes dead again... i really failed to judge why is this happening so guys plz help....
我还在下面粘贴了视频链接,展示了我的应用程序的这种烦人行为
i have also pasted link of video below showing this annoying behavior of my app
http://www.dailymotion.com/video/xlskk8_android-app-edit-text-error_tech
我在滚动视图中的布局 xml 是
my layout xml inside scroll view is
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="-110dip"
android:layout_marginBottom="5dip"
android:id="@+id/notes_editor"
android:orientation="vertical"
>
<EditText
android:id="@+id/enter_note"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:maxLines="2"
android:lines="2">
</EditText>
<Button
android:id="@+id/save_note"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Save" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-10dip"
android:id="@+id/notes_list"
android:orientation="vertical"
>
</LinearLayout>
</LinearLayout>
按钮下方的空线性布局用于动态添加子视图,所有其他内容均正常执行其功能,只有编辑文本显示此异常行为.
the empty linear layout below button is used for dynamically adding child views all other things are performing their functionality properly, only the edit text showing this abnormal behavior.
用于动画的代码如下
public void animateEditor()
{
slider = new TranslateAnimation(0, 0, 0,180 );
slider.setDuration(1250);
slider.setFillAfter(true);
notes_list.startAnimation(slider);
notes_editor.startAnimation(slider);
}
这里的问题是当应用 slider.setFillAfter(true);
代码动画视图的图像而不是实际的视图为什么当我在滑下动画后看到它们时它们(EditText 和保存按钮)卡住了,或者你可以说死了而不听他们的事件,因为实际的视图在布局后面,而在前面它只是他们的图像
The problem here was when applying slider.setFillAfter(true);
the code animates the image of Views but not the actual Views that's why when I see them after sliding down animation they were (EditText and save button) stuck or you can say dead and not listening to their events because actual Views were there behind the layout and at front it was just their image
我为该问题找到的解决方案是应用以下代码:
The solution I found for that problem is to apply following code:
slider.setFillAfter(false);
slider.setFillBefore(false);
// OR you can directly write
slider.setFillEnabled(false);
然后通过设置动画监听器并使用以下方法显示新位置的实际视图:
And then to show actual views on the new place by setting animation listener and using the following method:
public void onAnimationEnd(Animation a)
使用上述方法在动画结束时将视图放置到新位置.这里还有另一个闪烁问题,这是由于 android 动画侦听器方法中的问题,即它在实际动画结束之前被调用并导致闪烁效果,一个棘手的解决方案是将以下代码行放在第一行public void onAnimationEnd(Animation a)
方法.
Placing the views to new position at the end of animation by using above method. And here still comes another problem of blinking which is due to the problem in android animation listener method which is that it is get called before actually animation ends and causes blinking effect, a tricky solution to it is by putting following line of code at first line of public void onAnimationEnd(Animation a)
method.
// in my case animation applied to notes_editor so the code will be
notes_editor.clearAnimation();
这篇关于EditText 在动画后卡住并在滚动时重新活着......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!