Android: problems with edittext animation?

I tried to animate the edittext when the user started editing it. I tried the following code,

EditText txtPassword = (EditText) findViewById(R.id.editText1); Animation anim = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.anim); anim.setInterpolator((new AccelerateDecelerateInterpolator())); anim.setFillAfter(true); txtPassword.startAnimation(anim); anim.xml ```````` <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="0" android:toYDelta="-50%p" android:duration="100"/> </set> 

Animation works great. but edittext stopped user interaction after the animation. If the user touches the previous position of the edittext screen, a keyboard will appear. but the text editor is actually in a new position should respond. What should I do?

enter image description here

enter image description here I hope someone can edit my question in the correct English format.

+8
android android-edittext animation
source share
1 answer

(USEFUL INFORMATION: There is an Android library for using the Honeycomb Animation API (Android 3.0) on all versions of the platform prior to 1.0 !. It is called NineOldAndroid .)

(USEFUL INFORMATION (Android developers, View ): starting with Android 3.0, the preferred way to animate views is to use the android package APIs. These Animator-based classes modify the actual properties of the View object, such as alpha and translationX. This behavior is different from the behavior of classes pre-3.0 Animations, which instead only bring to life how the view is created. In particular, the ViewPropertyAnimator class makes animating these View properties particularly simple and efficient.)

(NOTE: THE SOLUTION BELOW IS NOT INTENDED).

Animations with android are a little more difficult to understand, unlike iOS. You need to know this

  • only the ghost of the Android View subclass is animated.
  • and the grave is still in the coordinate of the ancestor

So the solution could be:

  • Block touch events for viewing

    animatingView.setEnabled(FALSE);

  • animated view

  • Remove View Animation

    animatingView.setVisibility(GONE); (animatingView.getParent()).removeView(animatingView);

  • Add an exact duplicate of the view to the new coordinates.

0
source share

All Articles