2016-02-22 50 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]