2011-09-02 2 views
0

내가 3D 전환을 할 때보기가 잠시 중단되고 두 개의보기가 회전됩니다. 첫 번째보기에는 목록보기가 포함되어 있고 두 번째보기에는 목록보기가 모두 있습니다. 데이터베이스와

(고정 코드 블록)이 아닌 3 차원 거래를하는 동안내가 3D 전환을 수행 할 때 애니메이션이 언젠가 멈추다

/** 
* Setup a new 3D rotation on the container view. 
* 
* @param position the item that was clicked to show a picture, or -1 to show the list 
* @param start the start angle at which the rotation must begin 
* @param end the end angle of the rotation 
*/ 

private void applyRotation(int position, float start, float end) { 
    // Find the center of the container 
    final float centerX = mContainer.getWidth()/2.0f; 
    final float centerY = mContainer.getHeight()/2.0f; 

    final float centerX2 = mContainerView.getWidth()/2.0f; 
    final float centerY2 = mContainerView.getHeight()/2.0f; 

    // Create a new 3D rotation with the supplied parameter 
    // The animation listener is used to trigger the next animation 
    final Rotate3dAnimation rotation = 
      new Rotate3dAnimation(start, end, centerX, centerY, 310.0f, true); 
    rotation.setDuration(500); 
    rotation.setFillAfter(true); 
    rotation.setInterpolator(new AccelerateInterpolator()); 
    rotation.setAnimationListener(new DisplayNextView(position)); 

    mContainer.startAnimation(rotation); 

    //for view 
    final Rotate3dAnimation rotation2 = 
      new Rotate3dAnimation(start, end, centerX2, centerY2, 310.0f, true); 
    rotation2.setDuration(500); 
    rotation2.setFillAfter(true); 
    rotation2.setInterpolator(new AccelerateInterpolator()); 
    //rotation2.setAnimationListener(new DisplayNextView(position)); 
    mContainerView.startAnimation(rotation2); 
} 

/** 
* This class listens for the end of the first half of the animation. 
* It then posts a new action that effectively swaps the views when the container 
* is rotated 90 degrees and thus invisible. 
*/ 

private final class DisplayNextView implements Animation.AnimationListener { 
    private final int mPosition; 

    private DisplayNextView(int position) { 
     mPosition = position; 
    } 

    public void onAnimationStart(Animation animation) { 
    } 

    public void onAnimationEnd(Animation animation) { 
     mContainer.post(new SwapViews(mPosition)); 
    } 

    public void onAnimationRepeat(Animation animation) { 
    } 
} 

/** 
* This class is responsible for swapping the views and start the second 
* half of the animation. 
*/ 

private final class SwapViews implements Runnable { 
    private final int mPosition; 

    public SwapViews(int position) { 
     mPosition = position; 
    } 

    public void run() { 
     final float centerX = mContainer.getWidth()/2.0f; 
     final float centerY = mContainer.getHeight()/2.0f; 
     Rotate3dAnimation rotation; 

     final float centerX2 = mContainerView.getWidth()/2.0f; 
     final float centerY2 = mContainerView.getHeight()/2.0f; 
     Rotate3dAnimation rotation2; 

     if (mPosition==2) { 
      mButtonCounty.setVisibility(Button.GONE); 
      mButtonRadar.setVisibility(Button.VISIBLE); 
      mButtonRadar.requestFocus(); 

      mNearShopsView.setVisibility(LinearLayout.GONE); 
      mCountyListView.setVisibility(RelativeLayout.VISIBLE); 
      mCountyListView.requestFocus(); 

      rotation = new Rotate3dAnimation(90, 180, centerX, centerY, 310.0f, false); 

      rotation2 = new Rotate3dAnimation(90,180, centerX2, centerY2, 310.0f, false); 
     } else { 
      mButtonRadar.setVisibility(Button.GONE); 
      mButtonCounty.setVisibility(Button.VISIBLE); 
      mButtonCounty.requestFocus(); 

      mCountyListView.setVisibility(RelativeLayout.GONE); 
      mNearShopsView.setVisibility(LinearLayout.VISIBLE); 
      mNearShopsView.requestFocus(); 

      rotation = new Rotate3dAnimation(90, 0, centerX, centerY, 310.0f, false); 
      rotation2 = new Rotate3dAnimation(90,0, centerX2, centerY2, 310.0f, true); 
     } 

     rotation.setDuration(50); 
     rotation.setFillAfter(false); 
     rotation.setInterpolator(new DecelerateInterpolator()); 

     mContainer.startAnimation(rotation); 

     rotation2.setDuration(50); 
     rotation2.setFillAfter(false); 
     rotation2.setInterpolator(new DecelerateInterpolator()); 

     mContainerView.startAnimation(rotation2); 
    } 
} 

답변

0

당신은이 "중지"얻을 상호 작용? 그렇지 않다면보기에 DrawingCache을 사용하도록 설정해야합니다. 이것은 애니메이션의 모든 단계에서 다시 그리기 때문에 TextViews에서 주로 효과가 있습니다. 조회수에 View.setDrawingCacheEnabled(true);을 설정하십시오.

관련 문제