private void gotoMenu() {
   if (userPagelayout != null) {
     isAnimationOpen = !isAnimationOpen;
     if (isAnimationOpen) {
       if (mainMenu != null) {
         mainMenu.setIsCanClick(true);
       }
       mHandler.removeMessages(MessageID.MESSAGE_CONNECT_LAYOUTOVER);
       Animation animation = AnimationUtils.loadAnimation(this, R.anim.right_out);
       animation.setFillEnabled(true);
       animation.setFillAfter(true);
       animation.setAnimationListener(this);
       // 动画播放,实际布局坐标不变
       userPagelayout.startAnimation(animation);
       OfflineLog.writeMainMenu(); // 写入离线日志
     } else {
       if (mainMenu != null) {
         mainMenu.setIsCanClick(false);
       }
       Animation animation = AnimationUtils.loadAnimation(this, R.anim.left_in);
       animation.setAnimationListener(this);
       animation.setFillEnabled(true);
       animation.setFillAfter(true);
       userPagelayout.startAnimation(animation);
     }
   }
 }
  private void moveLeft(cgCacheView holder, cgCache cache, boolean force) {
    if (cache == null) {
      return;
    }

    holder.checkbox.setChecked(cache.isStatusChecked());

    // slide cache info
    final Animation hideCheckbox =
        new TranslateAnimation((int) (SWIPE_DISTANCE * pixelDensity), 0, 0, 0);
    hideCheckbox.setRepeatCount(0);
    hideCheckbox.setDuration(force ? 0 : 400);
    hideCheckbox.setFillEnabled(true);
    hideCheckbox.setFillAfter(true);
    hideCheckbox.setInterpolator(new AccelerateDecelerateInterpolator());

    // brighten cache info
    final Animation brightenInfo = new AlphaAnimation(SWIPE_OPACITY, 1.0f);
    brightenInfo.setRepeatCount(0);
    brightenInfo.setDuration(force ? 0 : 400);
    brightenInfo.setFillEnabled(true);
    brightenInfo.setFillAfter(true);
    brightenInfo.setInterpolator(new AccelerateDecelerateInterpolator());

    // animation set (container)
    final AnimationSet selectAnimation = new AnimationSet(true);
    selectAnimation.setFillEnabled(true);
    selectAnimation.setFillAfter(true);

    selectAnimation.addAnimation(hideCheckbox);
    selectAnimation.addAnimation(brightenInfo);

    holder.oneInfo.startAnimation(selectAnimation);
    cache.setStatusCheckedView(false);
  }
  private void initAnim() {

    long duration = 300;
    long durationS = 160;
    float alpha = 0.3f;
    AccelerateInterpolator accInterpolator = new AccelerateInterpolator();

    tab_left = new TranslateAnimation(tabW, 0, 0, 0);
    tab_right = new TranslateAnimation(0, tabW, 0, 0);
    tab_alpha_1 = new AlphaAnimation(1.0f, alpha);
    tab_alpha_2 = new AlphaAnimation(alpha, 1.0f);
    pop_in =
        new ScaleAnimation(
            0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
    pop_out =
        new ScaleAnimation(
            1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);

    pop_in.setDuration(durationS);
    pop_in.setInterpolator(accInterpolator);
    pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN));

    pop_out.setDuration(durationS);
    pop_out.setInterpolator(accInterpolator);
    pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT));

    tab_left.setFillAfter(true);
    tab_left.setFillEnabled(true);
    tab_left.setDuration(duration);
    tab_left.setInterpolator(accInterpolator);

    tab_right.setFillAfter(true);
    tab_right.setFillEnabled(true);
    tab_right.setDuration(duration);
    tab_right.setInterpolator(accInterpolator);

    tab_alpha_1.setFillAfter(true);
    tab_alpha_1.setFillEnabled(true);
    tab_alpha_1.setDuration(duration);
    tab_alpha_1.setInterpolator(accInterpolator);

    tab_alpha_2.setFillAfter(true);
    tab_alpha_2.setFillEnabled(true);
    tab_alpha_2.setDuration(duration);
    tab_alpha_2.setInterpolator(accInterpolator);

    AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha);
    alphaInit.setFillAfter(true);
    alphaInit.setFillEnabled(true);
    tv_tab_box.startAnimation(alphaInit);
  }
示例#4
0
 /** Flash camera preview, then display a white overlay. */
 private void overlayPreview() {
   final Animation animation = new AlphaAnimation(1.0f, 0.8f);
   animation.setDuration(750);
   animation.setInterpolator(getActivity(), android.R.interpolator.decelerate_cubic);
   animation.setFillAfter(true);
   animation.setFillEnabled(true);
   mFlashView.setVisibility(View.VISIBLE);
   mFlashView.startAnimation(animation);
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_well_come);
   imageView = (ImageView) findViewById(R.id.welcome_image_view);
   alphaAnimation = AnimationUtils.loadAnimation(this, R.anim.welcome_alpha);
   alphaAnimation.setFillEnabled(true); // 启动Fill保持
   alphaAnimation.setFillAfter(true); // 设置动画的最后一帧是保持在View上面
   imageView.setAnimation(alphaAnimation);
   alphaAnimation.setAnimationListener(this); // 为动画设置监听
 }
示例#6
0
  private void initAnimation() {
    final Interpolator interpolator = new LinearInterpolator();

    mTranslateAnimationIn =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF,
            0,
            Animation.RELATIVE_TO_SELF,
            0,
            Animation.RELATIVE_TO_SELF,
            -1f,
            Animation.RELATIVE_TO_SELF,
            0);
    mTranslateAnimationIn.setInterpolator(interpolator);
    mTranslateAnimationIn.setDuration(300);
    mTranslateAnimationIn.setFillBefore(true);
    mTranslateAnimationIn.setFillAfter(false);
    mTranslateAnimationIn.setFillEnabled(true);

    mTranslateAnimationOut =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF,
            0,
            Animation.RELATIVE_TO_SELF,
            0,
            Animation.RELATIVE_TO_SELF,
            0,
            Animation.RELATIVE_TO_SELF,
            -1f);
    mTranslateAnimationOut.setInterpolator(interpolator);
    mTranslateAnimationOut.setDuration(300);
    mTranslateAnimationOut.setFillAfter(true);

    mScaleAnimation1 = initScaleAnimation();
    mScaleAnimation2 = initScaleAnimation();
    mScaleAnimation3 = initScaleAnimation();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Intent callingIntent = getIntent();
    mAnimationType = callingIntent.getIntExtra("animation", KYLE_DEATH);

    if (mAnimationType == KYLE_DEATH) {
      setContentView(R.layout.animation_player);

      ImageView canvasImage = (ImageView) findViewById(R.id.animation_canvas);
      canvasImage.setImageResource(R.anim.kyle_fall);
      mAnimation = (AnimationDrawable) canvasImage.getDrawable();
    } else {
      if (mAnimationType == WANDA_ENDING || mAnimationType == KABOCHA_ENDING) {
        float startX = 0.0f;
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        if (mAnimationType == WANDA_ENDING) {
          setContentView(R.layout.good_ending_animation);
          startX = 200 * metrics.density;
        } else {
          setContentView(R.layout.kabocha_ending_animation);
          startX = -200 * metrics.density;
        }

        // HACK
        // The TranslateAnimation system doesn't support device independent
        // pixels. So for the Wanda ending and Kabocha endings, in which the
        // game over text scrolls in horizontally, compute the size based on
        // the actual density of the display and just generate the anim in
        // code.  The Rokudou animation can be safely loaded from a file.
        Animation gameOverAnim = new TranslateAnimation(startX, 0, 0, 0);
        gameOverAnim.setDuration(6000);
        gameOverAnim.setFillAfter(true);
        gameOverAnim.setFillEnabled(true);
        gameOverAnim.setStartOffset(8000);

        View background = findViewById(R.id.animation_background);
        View foreground = findViewById(R.id.animation_foreground);
        View gameOver = findViewById(R.id.game_over);

        Animation foregroundAnim =
            AnimationUtils.loadAnimation(this, R.anim.horizontal_layer2_slide);
        Animation backgroundAnim =
            AnimationUtils.loadAnimation(this, R.anim.horizontal_layer1_slide);

        background.startAnimation(backgroundAnim);
        foreground.startAnimation(foregroundAnim);
        gameOver.startAnimation(gameOverAnim);

        mAnimationEndTime = gameOverAnim.getDuration() + System.currentTimeMillis();
      } else if (mAnimationType == ROKUDOU_ENDING) {
        setContentView(R.layout.rokudou_ending_animation);
        View background = findViewById(R.id.animation_background);
        View sphere = findViewById(R.id.animation_sphere);
        View cliffs = findViewById(R.id.animation_cliffs);
        View rokudou = findViewById(R.id.animation_rokudou);
        View gameOver = findViewById(R.id.game_over);

        Animation backgroundAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_bg);
        Animation sphereAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_sphere);
        Animation cliffsAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_cliffs);
        Animation rokudouAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_rokudou);
        Animation gameOverAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_game_over);

        background.startAnimation(backgroundAnim);
        sphere.startAnimation(sphereAnim);
        cliffs.startAnimation(cliffsAnim);
        rokudou.startAnimation(rokudouAnim);
        gameOver.startAnimation(gameOverAnim);
        mAnimationEndTime = gameOverAnim.getDuration() + System.currentTimeMillis();
      } else {
        assert false;
      }
    }
    // Pass the calling intent back so that we can figure out which animation just played.
    setResult(RESULT_OK, callingIntent);
  }
示例#8
0
  public FiveLayout(View m, View l, View r, View t, View b) {
    this.main = m;
    this.left = l;
    this.right = r;
    this.top = t;
    this.bottom = b;

    left_show_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, -1,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0);
    left_show_anim.setDuration(300);
    left_show_anim.setFillEnabled(true);
    left_show_anim.setFillBefore(true);
    left_show_anim.setFillAfter(true);

    left_hide_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, -1,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0);
    left_hide_anim.setDuration(300);
    left_hide_anim.setFillEnabled(true);
    left_hide_anim.setFillBefore(true);
    left_hide_anim.setFillAfter(true);
    left_hide_anim.setAnimationListener(this);

    right_show_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 1,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0);
    right_show_anim.setDuration(300);
    right_show_anim.setFillEnabled(true);
    right_show_anim.setFillBefore(true);
    right_show_anim.setFillAfter(true);

    right_hide_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 1,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0);
    right_hide_anim.setDuration(300);
    right_hide_anim.setFillEnabled(true);
    right_hide_anim.setFillBefore(true);
    right_hide_anim.setFillAfter(true);
    right_hide_anim.setAnimationListener(this);

    // top
    top_show_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, -1,
            Animation.RELATIVE_TO_SELF, 0);
    top_show_anim.setDuration(200);
    top_show_anim.setFillEnabled(true);
    top_show_anim.setFillBefore(true);
    top_show_anim.setFillAfter(true);

    top_hide_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, -1);
    top_hide_anim.setDuration(200);
    top_hide_anim.setFillEnabled(true);
    top_hide_anim.setFillBefore(true);
    top_hide_anim.setFillAfter(true);
    top_hide_anim.setAnimationListener(this);

    // bottom
    bottom_show_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 1,
            Animation.RELATIVE_TO_SELF, 0);
    bottom_show_anim.setDuration(200);
    bottom_show_anim.setFillEnabled(true);
    bottom_show_anim.setFillBefore(true);
    bottom_show_anim.setFillAfter(true);

    bottom_hide_anim =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 1);
    bottom_hide_anim.setDuration(200);
    bottom_hide_anim.setFillEnabled(true);
    bottom_hide_anim.setFillBefore(true);
    bottom_hide_anim.setFillAfter(true);
    bottom_hide_anim.setAnimationListener(this);

    this.notifyLeftOn(false);
    this.notifyRightOn(false);
    this.notifyTopOn(false);
    this.notifyBottomOn(true);
  }