本文整理匯總了Java中android.view.animation.AnimationSet.setFillBefore方法的典型用法代碼示例。如果您正苦於以下問題:Java AnimationSet.setFillBefore方法的具體用法?Java AnimationSet.setFillBefore怎麽用?Java AnimationSet.setFillBefore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.animation.AnimationSet
的用法示例。
在下文中一共展示了AnimationSet.setFillBefore方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAdapterInsertAnimation
import android.view.animation.AnimationSet; //導入方法依賴的package包/類
public static void setAdapterInsertAnimation(final View aCard, int row, int height) {
final int ANIMATION_DURATION = 650;
final int BASE_DELAY = 50;
TranslateAnimation translationAnimation = new TranslateAnimation(0,0, height,0);
AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
final AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(translationAnimation);
animationSet.addAnimation(alphaAnimation);
animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
animationSet.setFillAfter(true);
animationSet.setFillBefore(true);
animationSet.setDuration(ANIMATION_DURATION + row * BASE_DELAY);
aCard.setAnimation(animationSet);
}
示例2: display
import android.view.animation.AnimationSet; //導入方法依賴的package包/類
public void display(float x) {
this.startPositionX = x;
this.lastPositionX = x;
recordButtonFab.setVisibility(View.VISIBLE);
float translation = ViewCompat.getLayoutDirection(recordButtonFab) ==
ViewCompat.LAYOUT_DIRECTION_LTR ? -.25f : .25f;
AnimationSet animation = new AnimationSet(true);
animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, translation,
Animation.RELATIVE_TO_SELF, translation,
Animation.RELATIVE_TO_SELF, -.25f,
Animation.RELATIVE_TO_SELF, -.25f));
animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
Animation.RELATIVE_TO_SELF, .5f,
Animation.RELATIVE_TO_SELF, .5f));
animation.setFillBefore(true);
animation.setFillAfter(true);
animation.setDuration(ANIMATION_DURATION);
animation.setInterpolator(new OvershootInterpolator());
recordButtonFab.startAnimation(animation);
}
示例3: hide
import android.view.animation.AnimationSet; //導入方法依賴的package包/類
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: clear
import android.view.animation.AnimationSet; //導入方法依賴的package包/類
/**
* Hides every currently shown element in the recyclerview. When the last view has been hidden
* clearNoAnimation() is called
* @return The time is takes for the last element to hide
*/
public int clear() {
final int ANIMATION_DURATION = 300;
final int BASE_DELAY = 50;
int startPosition = mRecyclerView.getManager().findFirstVisibleItemPosition();
int endPosition = mRecyclerView.getManager().findLastVisibleItemPosition();
int timeBeforeLastAnimIsDone = ANIMATION_DURATION;
for(int i = startPosition; i <= endPosition; i++) {
int delay = (i - startPosition) * BASE_DELAY;
final int finalI = i;
final int TRANSLATE_LENGTH = context.getResources().getDisplayMetrics().heightPixels;
Animation mTranslateAnim = new TranslateAnimation(0, 0, 0, TRANSLATE_LENGTH);
Animation mAlphaAnim = new AlphaAnimation(1f, 0f);
final AnimationSet mAnimSet = new AnimationSet(true);
mAnimSet.addAnimation(mTranslateAnim);
mAnimSet.addAnimation(mAlphaAnim);
mAnimSet.setDuration(ANIMATION_DURATION);
mAnimSet.setInterpolator(new AccelerateDecelerateInterpolator());
mAnimSet.setFillAfter(true);
mAnimSet.setFillBefore(true);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
View v = mRecyclerView.getManager().getChildAt(finalI);
if(v != null) {
v.startAnimation(mAnimSet);
}
}
}, delay);
if(i == endPosition) {
timeBeforeLastAnimIsDone = ANIMATION_DURATION + delay;
}
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
clearNoAnimation();
}
}, timeBeforeLastAnimIsDone);
return timeBeforeLastAnimIsDone;
}