下面这类的具体作用是?

皎秽是焦慧的交汇 Android项目开发实战-2... 06月05日提问

  • 0 回答
  • 109 浏览

private void initLayer(){

}

public void createMoveAnim(final Card from,final Card to,int fromX,int toX,int fromY,int toY){

final Card c = getCard(from.getNum());

LayoutParams lp = new LayoutParams(Config.CARD_WIDTH, Config.CARD_WIDTH);

lp.leftMargin = fromX*Config.CARD_WIDTH;

lp.topMargin = fromY*Config.CARD_WIDTH;

c.setLayoutParams(lp);

if (to.getNum()<=0) {

to.getLabel().setVisibility(View.INVISIBLE);

}

TranslateAnimation ta = new TranslateAnimation(0, Config.CARD_WIDTH*(toX-fromX), 0, Config.CARD_WIDTH*(toY-fromY));

ta.setDuration(100);

ta.setAnimationListener(new Animation.AnimationListener() {

@Override

public void onAnimationStart(Animation animation) {}

@Override

public void onAnimationRepeat(Animation animation) {}

@Override

public void onAnimationEnd(Animation animation) {

to.getLabel().setVisibility(View.VISIBLE);

recycleCard(c);

}

});

c.startAnimation(ta);

}

private Card getCard(int num){

Card c;

if (cards.size()>0) {

c = cards.remove(0);

}else{

c = new Card(getContext());

addView(c);

}

c.setVisibility(View.VISIBLE);

c.setNum(num);

return c;

}

private void recycleCard(Card c){

c.setVisibility(View.INVISIBLE);

c.setAnimation(null);

cards.add(c);

}

private List<Card> cards = new ArrayList<Card>();

public void createScaleTo1(Card target){

ScaleAnimation sa = new ScaleAnimation(0.1f, 1, 0.1f, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

sa.setDuration(100);

target.setAnimation(null);

target.getLabel().startAnimation(sa);

}