0

I am animating a Relativelayout in my application that has a spinner in it.The layout animates just fine but the problem is I cannot select the Spinner after the animation.I am new to animation.Please Help me!!Below is the code: MainActivity.java:

Animation slideup=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_up);
               relativeLayout1.startAnimation(slideup);
               slideup.setFillAfter(true);

slide_up(anim):

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromYDelta="0%p"
        android:toYDelta="-20%p"
        android:duration="2000"/>
</set>
jobin
  • 1,489
  • 5
  • 27
  • 52

1 Answers1

0

This is because Animations affects only the drawing of widget. However, The real Location is not affected -It is still in the previous one-.

To overcome this problem, you need to update the layout parameters of the Spinner manually by installing an animation listener as follows:

Animation.setAnimationListener(new AnimationListener() {
        public void onAnimationStart(Animation arg0) {

        }

        public void onAnimationRepeat(Animation arg0) {
            //TODO Auto-generated method stub
        }

        public void onAnimationEnd(Animation arg0) {
            android.widget.LinearLayout.LayoutParams params = new LayoutParams(
            android.widget.LinearLayout.LayoutParams.FILL_PARENT,
            android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
            params.topMargin = addLocationButton.getTop()-100;

            Spinner.setLayoutParams(params);
        }
        });

for more detail visit here : TranslateAnimated ImageView not clickable after animation [Android]

Community
  • 1
  • 1
Harshad
  • 1,344
  • 1
  • 10
  • 25