2015-02-08 31 views
0

我想完成移動部件後,停止動畫和移動其他部件,既所有動畫都必須完成之後將停止,不以前的遞歸狀態的Android動畫動,停在這簡單的移動動畫移動其他部件

動起來的xml:

<set xmlns:android="http://schemas.android.com/apk/res/android" > 

    <translate 
     android:duration="1000" 
     android:fromYDelta="0%" 
     android:toYDelta="-100%" /> 

</set> 

向下移動XML:

<set xmlns:android="http://schemas.android.com/apk/res/android" > 

    <translate 
     android:duration="1000" 
     android:fromYDelta="-100%" 
     android:toYDelta="0%" /> 

</set> 

我的代碼:

public class ActivitySmsReceiveSlave extends Activity implements AnimationListener { 
    private Animation       animMoveUp; 
    private Animation       animMoveDown; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_sms_receive_slave_view); 
     G.currentActivity = this; 
     animMoveUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.animation_move_up); 
     animMoveUp.setAnimationListener(this); 

     animMoveDown = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.animation_move_up); 

     detaileLinearLayout.startAnimation(animMoveUp); 
    @Override 
    public void onAnimationStart(Animation animation) { 
     // TODO Auto-generated method stub 

    } 
    @Override 
    public void onAnimationEnd(Animation animation) { 
     // TODO Auto-generated method stub 
     if (animation == animMoveUp) { 
      testLinear.startAnimation(animMoveDown); 
     } 
    } 
    @Override 
    public void onAnimationRepeat(Animation animation) { 
    } 
} 
在我的XML動畫和代碼

,做完後移或下移動畫,小部件遞歸開始的狀態,testLinear小部件不開始動畫

回答

-1
package com.example.testmove; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.animation.Animation; 
import android.view.animation.Animation.AnimationListener; 
import android.view.animation.AnimationUtils; 
import android.widget.ImageView; 

public class MainActivity extends Activity implements AnimationListener { 
    private Animation animMoveUp; 
    private Animation animMoveDown; 
    ImageView img; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     img=(ImageView)findViewById(R.id.imageView1); 
     animMoveUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.movedown); 
     animMoveUp.setAnimationListener(this); 

     animMoveDown = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.moveup); 
     animMoveDown.setAnimationListener(this); 
     img.startAnimation(animMoveUp); 

    } 
    @Override 
    public void onAnimationStart(Animation animation) { 
     // TODO Auto-generated method stub 

    } 
    @Override 
    public void onAnimationEnd(Animation animation) { 
     // TODO Auto-generated method stub 
     if (animation == animMoveUp) { 
      img.startAnimation(animMoveDown); 
     } 
     if(animation == animMoveDown){ 
      img.setAnimation(null);  } 
    } 
    @Override 
    public void onAnimationRepeat(Animation animation) { 
    } 
} 
+0

你爲什麼垂頭喪氣我的回答是工作我運行,然後發佈這個答案,如果你有任何麻煩,然後問,如果你想全力支持,那麼你必須發送給我的這個程序的佈局,我試圖做你想要的東西............ – 2015-02-08 10:20:07

+0

我的問題是在XML動畫文件,我可以修復它 – 2015-02-08 11:09:24

+0

那麼你爲什麼低調我的答案是正確的........ – 2015-02-09 04:12:22