本文整理匯總了Java中android.view.animation.Animation.ABSOLUTE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Animation.ABSOLUTE屬性的具體用法?Java Animation.ABSOLUTE怎麽用?Java Animation.ABSOLUTE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.animation.Animation
的用法示例。
在下文中一共展示了Animation.ABSOLUTE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: moveTo
public void moveTo(float x) {
this.lastPositionX = x;
float offset = getOffset(x);
int widthAdjustment = getWidthAdjustment();
Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, widthAdjustment + offset,
Animation.ABSOLUTE, widthAdjustment + offset,
Animation.RELATIVE_TO_SELF, -.25f,
Animation.RELATIVE_TO_SELF, -.25f);
translateAnimation.setDuration(0);
translateAnimation.setFillAfter(true);
translateAnimation.setFillBefore(true);
recordButtonFab.startAnimation(translateAnimation);
}
示例2: moveTo
public void moveTo(float x) {
float offset = getOffset(x);
Animation animation = new TranslateAnimation(Animation.ABSOLUTE, offset,
Animation.ABSOLUTE, offset,
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);
animation.setDuration(0);
animation.setFillAfter(true);
animation.setFillBefore(true);
slideToCancelView.startAnimation(animation);
}
示例3: hide
public void hide(float x) {
this.lastPositionX = x;
float offset = getOffset(x);
int widthAdjustment = getWidthAdjustment();
AnimationSet animation = new AnimationSet(false);
Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment,
Animation.ABSOLUTE, widthAdjustment,
Animation.RELATIVE_TO_SELF, -.25f,
Animation.RELATIVE_TO_SELF, -.25f);
scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
translateAnimation.setInterpolator(new DecelerateInterpolator());
animation.addAnimation(scaleAnimation);
animation.addAnimation(translateAnimation);
animation.setDuration(ANIMATION_DURATION);
animation.setFillBefore(true);
animation.setFillAfter(false);
animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
recordButtonFab.setVisibility(View.GONE);
recordButtonFab.clearAnimation();
recordButtonFab.startAnimation(animation);
}
示例4: getTranslateAnimator
/**
* 獲取位移動畫
*/
private TranslateAnimation getTranslateAnimator(float targetX, float targetY) {
TranslateAnimation translateAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f,
Animation.ABSOLUTE, targetX,
Animation.RELATIVE_TO_SELF, 0f,
Animation.ABSOLUTE, targetY);
// RecyclerView默認移動動畫250ms 這裏設置360ms 是為了防止在位移動畫結束後 remove(view)過早 導致閃爍
translateAnimation.setDuration(ANIM_TIME);
translateAnimation.setFillAfter(true);
return translateAnimation;
}
示例5: onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_animations);
mCheckBox = (CheckBox) findViewById(R.id.checkbox);
final Button alphaButton = (Button) findViewById(R.id.alphaButton);
final Button translateButton = (Button) findViewById(R.id.translateButton);
final Button rotateButton = (Button) findViewById(R.id.rotateButton);
final Button scaleButton = (Button) findViewById(R.id.scaleButton);
final Button setButton = (Button) findViewById(R.id.setButton);
// Fade the button out and back in
final AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setDuration(1000);
// Move the button over and then back
final TranslateAnimation translateAnimation =
new TranslateAnimation(Animation.ABSOLUTE, 0,
Animation.RELATIVE_TO_PARENT, 1,
Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 100);
translateAnimation.setDuration(1000);
// Spin the button around in a full circle
final RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
rotateAnimation.setDuration(1000);
// Scale the button in X and Y.
final ScaleAnimation scaleAnimation = new ScaleAnimation(1, 2, 1, 2);
scaleAnimation.setDuration(1000);
// Run the animations above in sequence on the final button. Looks horrible.
final AnimationSet setAnimation = new AnimationSet(true);
setAnimation.addAnimation(alphaAnimation);
setAnimation.addAnimation(translateAnimation);
setAnimation.addAnimation(rotateAnimation);
setAnimation.addAnimation(scaleAnimation);
setupAnimation(alphaButton, alphaAnimation, R.anim.alpha_anim);
setupAnimation(translateButton, translateAnimation, R.anim.translate_anim);
setupAnimation(rotateButton, rotateAnimation, R.anim.rotate_anim);
setupAnimation(scaleButton, scaleAnimation, R.anim.scale_anim);
setupAnimation(setButton, setAnimation, R.anim.set_anim);
}