2013-03-29 4 views
2

뷰를 "슬라이드 아래쪽"으로 추가하고 뷰를 "슬라이드 업"으로 제거하려면 ViewGroup에 있습니다. 그래서 LayoutTransition.class을 사용했지만 minSdk 8에는 지원되지 않습니다. 그래서이 NineOldAndroids을 발견하고 내가 이것을 사용하여 원하는 것을 얻을 수 있는지 궁금해하고있었습니다. 이 같은NineOldAndroids의 LayoutTransition 클래스 ..?

뭔가가 진저 브레드에서 실행 할 수 없습니다로

LayoutTransition layoutTransition = new LayoutTransition(); 
     AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(getApplicationContext(), 
       R.anim.slide); 
     layoutTransition.setAnimator(LayoutTransition.APPEARING, set); 

답변

3

불행하게도 NineOldAndroids가 LayoutTransitions를 지원하지 않습니다.

0

LayoutTransition없이 뷰를 추가 할 때도 애니메이션을 적용해야합니다.

 
    // A fake AlphaAnimation so that we can know how to start the animation of adding view 
     Animation animation = new AlphaAnimation(0, 0); 
     animation.setDuration(1); 
     animation.setFillAfter(true); 
     animation.setAnimationListener(new Animation.AnimationListener() { 
      @Override 
      public void onAnimationStart(Animation animation) {
}

@Override public void onAnimationEnd(Animation animation) { // start the animation here startAddingViewAnimation(); } @Override public void onAnimationRepeat(Animation animation) { } }); ViewGroup viewroot = findViewById(R.id.viewroot); LayoutAnimationController layoutAnimationController = new LayoutAnimationController(animation); viewRoot.setLayoutAnimation(layoutAnimationController); viewRoot.addView(btn);

뷰를 추가하고 그릴 완료 한 저를 알리기 위해 LayoutAnimationController을 설정합니다 나는 때 그래서 을 할 LayoutAnimationController을 사용하여 애니메이션을 시작하는 아무 생각이 없습니다. 그러면 nineoldanimator로 애니메이션을 시작할 수 있습니다.