android.view.animation.Animation.setAnimationListener()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中android.view.animation.Animation.setAnimationListener()方法的一些代码示例,展示了Animation.setAnimationListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Animation.setAnimationListener()方法的具体详情如下:
包路径:android.view.animation.Animation
类名称:Animation
方法名:setAnimationListener

Animation.setAnimationListener介绍

暂无

代码示例

代码示例来源:origin: aa112901/remusic

@Override
  public void setAnimationListener(AnimationListener listener) {
    super.setAnimationListener(listener);
  }
};

代码示例来源:origin: north2016/T-MVP

public static void setAnimationListener(Animation aninm, final AnimListener listener) {
  aninm.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {
    }
    @Override
    public void onAnimationEnd(Animation animation) {
      listener.onAnimFinish();
    }
    @Override
    public void onAnimationRepeat(Animation animation) {
    }
  });
}

代码示例来源:origin: navasmdc/MaterialDesignLibrary

/**
 * @author Jack Tony
 */
@Override
public void dismiss() {
  Animation anim = AnimationUtils.loadAnimation(activity, R.anim.snackbar_hide_animation);
  anim.setAnimationListener(new AnimationListener() {
    
    @Override
    public void onAnimationStart(Animation animation) {
    }
    
    @Override
    public void onAnimationRepeat(Animation animation) {
    }
    
    @Override
    public void onAnimationEnd(Animation animation) {
      SnackBar.super.dismiss();
    }
  });
  view.startAnimation(anim);
}

代码示例来源:origin: aa112901/remusic

public void play() {
  if (mTargetView == null || mSnackInAnim == null || mSnackOutAnim == null) {
    return;
  }
  mTargetView.setVisibility(View.VISIBLE);
  mSnackInAnim.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {
    }
    @Override
    public void onAnimationEnd(Animation animation) {
      playSnackOutAnimation();
    }
    @Override
    public void onAnimationRepeat(Animation animation) {
    }
  });
  mTargetView.startAnimation(mSnackInAnim);
}

代码示例来源:origin: Ramotion/folding-cell-android

/**
 * Create "animation chain" for selected view from list of animation objects
 *
 * @param animationList   collection with animations
 * @param animationObject view for animations
 */
protected void createAnimationChain(final List<Animation> animationList, final View animationObject) {
  for (int i = 0; i < animationList.size(); i++) {
    Animation animation = animationList.get(i);
    if (i + 1 < animationList.size()) {
      final int finalI = i;
      animation.setAnimationListener(new AnimationEndListener() {
        public void onAnimationEnd(Animation animation) {
          animationObject.startAnimation(animationList.get(finalI + 1));
        }
      });
    }
  }
}

代码示例来源:origin: navasmdc/MaterialDesignLibrary

@Override
public void dismiss() {
  Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);
  
  anim.setAnimationListener(new AnimationListener() {
    
    @Override
    public void onAnimationStart(Animation animation) {
    }
    
    @Override
    public void onAnimationRepeat(Animation animation) {
    }
    
    @Override
    public void onAnimationEnd(Animation animation) {
      view.post(new Runnable() {
        @Override
        public void run() {
          ColorSelector.super.dismiss();
        }
      });
    }
  });
  
  Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);
  
  view.startAnimation(anim);
  backView.startAnimation(backAnim);
}

代码示例来源:origin: navasmdc/MaterialDesignLibrary

@Override
public void dismiss() {
  Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);
  anim.setAnimationListener(new AnimationListener() {
    
    @Override
    public void onAnimationStart(Animation animation) {
    }
    
    @Override
    public void onAnimationRepeat(Animation animation) {
    }
    
    @Override
    public void onAnimationEnd(Animation animation) {
      view.post(new Runnable() {
        @Override
        public void run() {
          ProgressDialog.super.dismiss();
        }
      });
      
    }
  });
  Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);
  
  view.startAnimation(anim);
  backView.startAnimation(backAnim);
}

代码示例来源:origin: navasmdc/MaterialDesignLibrary

@Override
public void dismiss() {
  Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);
  anim.setAnimationListener(new AnimationListener() {
    
    @Override
    public void onAnimationStart(Animation animation) {
    }
    
    @Override
    public void onAnimationRepeat(Animation animation) {
    }
    
    @Override
    public void onAnimationEnd(Animation animation) {
      view.post(new Runnable() {
        @Override
        public void run() {
          Dialog.super.dismiss();
        }
      });
      
    }
  });
  Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);
  
  view.startAnimation(anim);
  backView.startAnimation(backAnim);
}

代码示例来源:origin: rey5137/material

private void animOut(final View v){
  Animation anim = new AlphaAnimation(1f, 0f);
  anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
  anim.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {}
    @Override
    public void onAnimationEnd(Animation animation) {
      v.setVisibility(View.GONE);
    }
    @Override
    public void onAnimationRepeat(Animation animation) {}
  });
  v.startAnimation(anim);
}

代码示例来源:origin: stackoverflow.com

private void fadeOutAndHideImage(final ImageView img)
 {
  Animation fadeOut = new AlphaAnimation(1, 0);
  fadeOut.setInterpolator(new AccelerateInterpolator());
  fadeOut.setDuration(1000);

  fadeOut.setAnimationListener(new AnimationListener()
  {
      public void onAnimationEnd(Animation animation) 
      {
         img.setVisibility(View.GONE);
      }
      public void onAnimationRepeat(Animation animation) {}
      public void onAnimationStart(Animation animation) {}
  });

  img.startAnimation(fadeOut);
}

代码示例来源:origin: rey5137/material

private void animIn(final View v){
  Animation anim = new AlphaAnimation(0f, 1f);
  anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
  anim.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {
      v.setVisibility(View.VISIBLE);
    }
    @Override
    public void onAnimationEnd(Animation animation) {
    }
    @Override
    public void onAnimationRepeat(Animation animation) {
    }
  });
  v.startAnimation(anim);
}

代码示例来源:origin: rey5137/material

private void animOut(final View v, final boolean setGone, final boolean immediately){
  if(!isShowing() || v.getVisibility() != View.VISIBLE || immediately) {
    v.setVisibility(setGone ? View.GONE : View.INVISIBLE);
    return;
  }
  Animation anim = new AlphaAnimation(1f, 0f);
  anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
  anim.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {}
    @Override
    public void onAnimationEnd(Animation animation) {
      v.setVisibility(setGone ? View.GONE : View.INVISIBLE);
    }
    @Override
    public void onAnimationRepeat(Animation animation) {}
  });
  v.startAnimation(anim);
}

代码示例来源:origin: rey5137/material

private void animIn(final View v, boolean immediately){
  if(v.getVisibility() == View.VISIBLE)
    return;
  if(!isShowing() || immediately) {
    v.setVisibility(View.VISIBLE);
    return;
  }
  Animation anim = new AlphaAnimation(0f, 1f);
  anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
  anim.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {
      v.setVisibility(View.VISIBLE);
    }
    @Override
    public void onAnimationEnd(Animation animation) {}
    @Override
    public void onAnimationRepeat(Animation animation) {}
  });
  v.startAnimation(anim);
}

代码示例来源:origin: hidroh/materialistic

@Override
public void onAnimationEnd(Animation animation) {
  new Handler().postDelayed(mVoteSwitcher::showNext, VOTE_DELAY_MILLIS);
  mScoreTextView.setText(getContext().getResources()
      .getQuantityString(R.plurals.score, newScore, newScore));
  mVoteSwitcher.getInAnimation().setAnimationListener(null);
}

代码示例来源:origin: Clans/FloatingActionButton

@Override
public void onAnimationEnd(Animation animation) {
  setVisibility(GONE);
  getHideAnimation().setAnimationListener(null);
}

代码示例来源:origin: androidquery/androidquery

/**
 * Starts an animation on the view.
 * 
 * <br>
 * contributed by: marcosbeirigo
 * 
 * @param animId Id of the desired animation.
 * @param listener The listener to recieve notifications from the animation on its events.
 * @return self
 * 
 * 
 */
public T animate(int animId, AnimationListener listener){
  Animation anim = AnimationUtils.loadAnimation(getContext(), animId);
  anim.setAnimationListener(listener);
  return animate(anim);
}

代码示例来源:origin: JingYeoh/FragmentRigger

/**
 * Sets the to be animated view on hardware layer during the animation.Note
 * that calling this will replace any existing animation listener on the animation
 * with a new one, as animations do not support more than one listeners. Therefore,
 * animations that already have listeners should do the layer change operations
 * in their existing listeners, rather than calling this function.
 */
void setHWLayerAnimListenerIfAlpha(View v, Animation anim) {
  if (v == null || anim == null) {
    return;
  }
  if (shouldRunOnHWLayer(v, anim)) {
    anim.setAnimationListener(new AnimateOnHWLayerIfNeededListener(v, anim));
  }
}

代码示例来源:origin: huburt-Hu/NewbieGuide

public void remove() {
  Animation exitAnimation = guidePage.getExitAnimation();
  if (exitAnimation != null) {
    exitAnimation.setAnimationListener(new AnimationListenerAdapter() {
      @Override
      public void onAnimationEnd(Animation animation) {
        dismiss();
      }
    });
    startAnimation(exitAnimation);
  } else {
    dismiss();
  }
}

代码示例来源:origin: k9mail/k-9

private void setupAnimations(Animation in, Animation out) {
  if (K9.showAnimations()) {
    setInAnimation(in);
    setOutAnimation(out);
    out.setAnimationListener(this);
  } else {
    setInAnimation(null);
    setOutAnimation(null);
  }
}

代码示例来源:origin: robolectric/robolectric

@Test @Ignore("Needs additional work")
 public void start_shouldRunAnimation() {
  final AnimationSet set = new AnimationSet(true);

  final Animation move = new TranslateAnimation(0, 100, 0, 100);
  move.setDuration(1000);
  move.setAnimationListener(moveListener);

  final Animation spin = new RotateAnimation(0, 360);
  spin.setDuration(1000);
  spin.setStartOffset(1000);
  spin.setAnimationListener(spinListener);

  set.start();

  verify(moveListener).onAnimationStart(move);

  Robolectric.flushForegroundThreadScheduler();

  verify(moveListener).onAnimationEnd(move);
 }
}

相关文章