EditText stucks after animation and live back to scroll ......?

I came across a rather interesting but annoying mistake, in my linear layout I hid another linear layout using margin in the negative, and when the user selects a type from the list, I bring the layout to the front using Translational Animation, the error is that the layout comes to the fore, the edit text becomes dead, and when I scroll (my main layout is surrounded by scrolling), it comes to life, and when I stop scrolling, it becomes dead again ... I really did not understand why this happens, so guys pl z help ....

I also inserted a link to the video below, showing this annoying behavior of my application.

http://www.dailymotion.com/video/xlskk8_android-app-edit-text-error_tech

my xml layout inside scroll view

<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 the button is used to dynamically add child views, all other things perform their functionality properly, only the editing text shows this abnormal behavior.

animation code below

  public void animateEditor() { slider = new TranslateAnimation(0, 0, 0,180 ); slider.setDuration(1250); slider.setFillAfter(true); notes_list.startAnimation(slider); notes_editor.startAnimation(slider); } 
+8
android android-edittext
source share
1 answer

The problem here was applying slider.setFillAfter(true); the code that animates the Views image, but not the actual views, so when I see them after the animation crawls, they were (EditText and the save button) stuck, or you can say that they are dead and not listening to their events, because the actual the views were there for the layout, and at the front it was just their image

The solution I found for this problem is to apply the following code:

 slider.setFillAfter(false); slider.setFillBefore(false); // OR you can directly write slider.setFillEnabled(false); 

Then, to show the actual views in a new place by installing an animation listener and using the following method:

 public void onAnimationEnd(Animation a) 

Placing views in a new position at the end of the animation using the method described above. And here another flashing problem arises, which is associated with a problem in the method of listening to android animation, which is that it is called before the actual animation ends and causes a blinking effect, and the difficult solution is to put the next line of code on The first line of the method is public void onAnimationEnd(Animation a) .

 // in my case animation applied to notes_editor so the code will be notes_editor.clearAnimation(); 
+23
source share

All Articles