Uma*_*shi 8 android android-edittext
我面临着一个非常有趣但令人讨厌的错误,在我的线性布局中,我隐藏了另一个线性布局,使用了负片边距,当用户从列表中选择一个类型时,我使用Translational Animation将布局带到前面,错误是布局来到前面它有一个编辑文本,它变成死了,当我滚动(我的主要布局被滚动视图包围)它活跃起来,当我停止滚动它再次死了...我真的无法判断为什么这发生所以人们PLZ帮助. ...
我还粘贴了下面的视频链接,显示我的应用程序的这种令人讨厌的行为
http://www.dailymotion.com/video/xlskk8_android-app-edit-text-error_tech
我在滚动视图里面的布局xml是
<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>
Run Code Online (Sandbox Code Playgroud)
下面的空线性布局按钮用于动态添加子视图,所有其他东西正在正确执行其功能,只有编辑文本显示此异常行为.
用于动画的代码如下
public void animateEditor()
{
slider = new TranslateAnimation(0, 0, 0,180 );
slider.setDuration(1250);
slider.setFillAfter(true);
notes_list.startAnimation(slider);
notes_editor.startAnimation(slider);
}
Run Code Online (Sandbox Code Playgroud)
Uma*_*shi 24
这里的问题是当应用slider.setFillAfter(true);
代码动画视图的图像而不是实际的视图时,这就是为什么当我在滑动动画后看到它们(EditText和保存按钮)卡住或者你可以说死了而不是听他们的事件因为实际布局背后有观点,前面只是他们的形象
我发现该问题的解决方案是应用以下代码:
slider.setFillAfter(false);
slider.setFillBefore(false);
// OR you can directly write
slider.setFillEnabled(false);
Run Code Online (Sandbox Code Playgroud)
然后通过设置动画侦听器并使用以下方法显示新位置的实际视图:
public void onAnimationEnd(Animation a)
Run Code Online (Sandbox Code Playgroud)
使用上述方法将视图放置在动画结束时的新位置.这里仍然存在另一个闪烁的问题,这是由于android动画监听器方法中的问题,即它在实际动画结束之前被调用并导致闪烁效果,一个棘手的解决方案是通过在第一行放置以下代码行的public void onAnimationEnd(Animation a)
方法.
// in my case animation applied to notes_editor so the code will be
notes_editor.clearAnimation();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5364 次 |
最近记录: |