2016-02-22 47 views
0

我在我的应用程序中有一个动画片在它的动画片中。布局动画效果很好,但问题是动画后我无法选择微调器。我是动画新手。请帮助我!!下面是代码: MainActivity.java:android动画片在动画后不可点击

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

slide_up(动画):

<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <translate 
     android:fromYDelta="0%p" 
     android:toYDelta="-20%p" 
     android:duration="2000"/> 
</set> 

回答

0

这是因为动画只影响控件的绘制。但是,真正的位置不受影响 - 它仍然处于上一个位置。

为了克服这个问题,你需要手动安装一个动画监听器来更新微调的布局参数如下:

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); 
     } 
     }); 

的更多详情,请浏览:TranslateAnimated ImageView not clickable after animation [Android]