0
我知道這是非常簡單的事情,但我沒有看到問題。Android動畫無法啓動
我有一個的LinearLayout:
LinearLayout menuSlide = (LinearLayout) findViewById(R.id.menuSlide);
menuSlide.startAnimation(new ExpandAnimation(menuSlide, 0, (int) (screenWidth*0.7), 20));
而且ExpandAnimation類:
public class ExpandAnimation extends Animation implements Animation.AnimationListener{
private View view;
private static int ANIMATION_DURATION;
private static final String LOG_CAT = "ExpandAnimation";
private int lastWidth;
private int fromWidth;
private int toWidth;
private static int STEP_SIZE=30;
public ExpandAnimation(View v,int fromWidth, int toWidth, int duration){
Log.v(LOG_CAT, "Entramos en el constructor del ExpandAnimation");
this.view = v;
ANIMATION_DURATION = 1;
this.fromWidth = fromWidth;
this.toWidth = toWidth;
setDuration(ANIMATION_DURATION);
setRepeatCount(20);
setFillAfter(false);
setInterpolator(new AccelerateInterpolator());
setAnimationListener(this);
startNow();
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
Log.v(LOG_CAT, "Entra en el onAnimationRepeat");
LayoutParams lyp = view.getLayoutParams();
lyp.width = lastWidth += toWidth/20;
view.setLayoutParams(lyp);
Log.v(LOG_CAT,"El objeto: " + view.getId() + " tiene ahora de ancho: " + view.getWidth());
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
Log.v(LOG_CAT, "Entra en el onAnimationStart");
LayoutParams lyp = view.getLayoutParams();
lyp.width = 0;
view.setLayoutParams(lyp);
lastWidth=0;
}
}
確定,程序達到ExpandAnimation的構造,但沒有別的,onAnimationStart永遠不會被解僱。
我在做什麼錯了?
它仍然不會啓動動畫開始 – 2012-08-17 17:20:19