下面列出了android.view.animation.TranslateAnimation#ABSOLUTE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void intLayoutAnim()
{
Animation slideIn = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, -1, TranslateAnimation.ABSOLUTE, 0,
TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
slideIn.setDuration(KAnimTimeShort);
mAnimIn = new LayoutAnimationController(slideIn, LayoutAnimDelay);
Animation slideOut = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.RELATIVE_TO_SELF, -1,
TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
slideOut.setDuration(KAnimTimeShort);
slideOut.setFillAfter(true);
mAnimOut = new LayoutAnimationController(slideOut, LayoutAnimDelay);
mAnimOut.setOrder(LayoutAnimationController.ORDER_REVERSE);
mainMenu.setLayoutAnimation(mAnimIn);
mHideShowListener = new HideShowListener();
mainMenu.setLayoutAnimationListener(mHideShowListener);
mReady.autoSetVal(true, AnimationBlockTimer);
}
private void bounceBackHeader(){
int yTranslate = state == State.REFRESHING ?
header.getHeight() - headerContainer.getHeight() :
-headerContainer.getHeight() - headerContainer.getTop();
bounceAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE, 0,
TranslateAnimation.ABSOLUTE, 0,
TranslateAnimation.ABSOLUTE, 0,
TranslateAnimation.ABSOLUTE, yTranslate);
bounceAnimation.setDuration(BOUNCE_ANIMATION_DURATION);
bounceAnimation.setFillEnabled(true);
bounceAnimation.setFillAfter(false);
bounceAnimation.setFillBefore(true);
//bounceAnimation.setInterpolator(new OvershootInterpolator(BOUNCE_OVERSHOOT_TENSION));
bounceAnimation.setAnimationListener(new HeaderAnimationListener(yTranslate));
startAnimation(bounceAnimation);
}
void setUpTextBoxArrowAnimation(ImageView textboxArrow) {
TranslateAnimation textBoxArrowAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0.01f);
textBoxArrowAnimation.setDuration(500);
textBoxArrowAnimation.setRepeatCount(-1);
textBoxArrowAnimation.setRepeatMode(Animation.RESTART);
textBoxArrowAnimation.setInterpolator(new LinearInterpolator());
textBoxArrowAnimation.setFillAfter(true);
textboxArrow.setAnimation(textBoxArrowAnimation);
}
private void setUpTextBoxArrowAnimation() {
ImageView textBoxArrow = findViewById(R.id.textbox_box_arrow);
TranslateAnimation textBoxArrowAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0.01f);
textBoxArrowAnimation.setDuration(500);
textBoxArrowAnimation.setRepeatCount(-1);
textBoxArrowAnimation.setRepeatMode(Animation.RESTART);
textBoxArrowAnimation.setInterpolator(new LinearInterpolator());
textBoxArrowAnimation.setFillAfter(true);
textBoxArrow.setAnimation(textBoxArrowAnimation);
}