Java Code Examples for android.view.animation.Animation#setFillAfter()

The following examples show how to use android.view.animation.Animation#setFillAfter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WoDouGameBaseFragment.java    From android-tv-launcher with MIT License 6 votes vote down vote up
@Override
public void onFocusChange(View v, boolean hasFocus) {

    int focus = 0;
    if (hasFocus) {
        focus = R.anim.enlarge;
    } else {
        focus = R.anim.decrease;
    }
    //如果有焦点就放大,没有焦点就缩小
    Animation mAnimation = AnimationUtils.loadAnimation(
            getActivity().getApplication(), focus);
    mAnimation.setBackgroundColor(Color.TRANSPARENT);
    mAnimation.setFillAfter(hasFocus);
    v.startAnimation(mAnimation);
    mAnimation.start();
    v.bringToFront();
}
 
Example 2
Source File: MapWidget.java    From mappwidget with Apache License 2.0 5 votes vote down vote up
private Animation getZoomInAnimation(float pivotX, float pivotY) {
	float fromX = 1.0f;
	float fromY = 1.0f;
	float toX = 2.0f;
	float toY = 2.0f;

	Animation zoomInAnimation = new ScaleAnimation(fromX, toX, fromY, toY,
			pivotX, pivotY);
	zoomInAnimation.setDuration(500);
	zoomInAnimation.setInterpolator(decelerateInterpolator);
	zoomInAnimation.setFillAfter(true);

	return zoomInAnimation;
}
 
Example 3
Source File: RayLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createExpandAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
		long startOffset, long duration, Interpolator interpolator) {
	Animation animation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 0, 720);
	animation.setStartOffset(startOffset);
	animation.setDuration(duration);
	animation.setInterpolator(interpolator);
	animation.setFillAfter(true);

	return animation;
}
 
Example 4
Source File: ArcLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createExpandAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
        long startOffset, long duration, Interpolator interpolator) {
    Animation animation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 0, 720);
    animation.setStartOffset(startOffset);
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setFillAfter(true);

    return animation;
}
 
Example 5
Source File: DragSortGridView.java    From MissZzzReader with Apache License 2.0 5 votes vote down vote up
/**
 * @param from
 * @param to
 * @描述:动画效果移动View
 * @作者 [pWX273343] 2015年6月24日
 */
private void translateView(int from, int to) {
    View view = mChilds.get(from);
    int fromXValue = ((int[]) view.getTag(TAG_KEY))[0];
    int fromYValue = ((int[]) view.getTag(TAG_KEY))[1];
    int toXValue = to % mNumColumns - from % mNumColumns + fromXValue;
    int toYValue = to / mNumColumns - from / mNumColumns + fromYValue;
    Animation animation = new TranslateAnimation(1, fromXValue, 1, toXValue, 1, fromYValue, 1, toYValue);
    animation.setDuration(ANIM_DURING);
    animation.setFillAfter(true);
    view.setTag(TAG_KEY, new int[]{toXValue, toYValue});
    view.startAnimation(animation);
}
 
Example 6
Source File: CirclesWaveSpinner.java    From MillSpinners with Apache License 2.0 5 votes vote down vote up
private void init() {
    final LayoutParams tempArcViewLayoutParams = new LayoutParams(this.diameter, this.diameter);
    tempArcViewLayoutParams.gravity = Gravity.CENTER;

    for (int i = 0; i < this.circleViews.length; i++) {
        final CircleView tempCircleView = new CircleView(getContext());
        tempCircleView.setColor(this.colors[colorCounter++]);
        if (this.colorCounter == 3) {
            this.colorCounter = 0;
        }

        tempCircleView.setStartOffset((this.circleViews.length - 1 - i) * this.startOffset);
        tempCircleView.setStrokeWidth(this.strokeWidth);
        tempCircleView.setCircleMargin(this.marginCircleCounter += this.marginCircle);

        tempCircleView.setLayoutParams(tempArcViewLayoutParams);

        this.circleViews[i] = tempCircleView;
    }

    for (int i = this.circleViews.length - 1; i >= 0; i--) {
        this.addView(this.circleViews[i]);
        this.circleViews[i].init();
    }

    final Animation animation = new RotateAnimation(0, -45, this.radius, this.radius);
    animation.setFillAfter(true);
    startAnimation(animation);
}
 
Example 7
Source File: PaymentRequestSection.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    Animation out = new AlphaAnimation(mUpdatedView.getAlpha(), 0.0f);
    out.setDuration(UPDATE_TEXT_ANIMATION_DURATION_MS);
    out.setInterpolator(new LinearOutSlowInInterpolator());
    out.setFillAfter(true);
    mUpdatedView.startAnimation(out);
}
 
Example 8
Source File: PlayerService.java    From SpotifyTray-Android with MIT License 5 votes vote down vote up
private void changeSongDisplayInfo(){
	
	InputStream is=null;
	try {
		is = getAssets().open(mPlaylist.getCurrentSongInfo().mAlbumCoverPath);
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	// Load new bitmap
	Bitmap bmap = Utils.loadMaskedBitmap(is, mAlbumCoverLayout.getHeight(), mAlbumCoverLayout.getWidth());
	
	// Change backgrounds
	mAlbumCoverHelperLayout.setBackgroundDrawable(mAlbumCoverLayout.getBackground());
	mAlbumCoverLayout.setBackgroundDrawable(new BitmapDrawable(getResources(), bmap));
	
	// Animate the two layouts in order to achieve the fade in/fade out effect.
	// First normalise the distance between open and closed states (0-1)
	float relativeDistance = (mRootLayoutParams.x + mLogoLayout.getWidth())/(float)
			(-mRootLayout.getWidth()/TRAY_HIDDEN_FRACTION + mLogoLayout.getWidth());
	relativeDistance=Math.max(relativeDistance, 0);
	relativeDistance=Math.min(relativeDistance, 1);
	
	// Then use it to set final alpha in the animation.
	Animation fadeOutAnim = new AlphaAnimation(relativeDistance,0.f);
	fadeOutAnim.setFillAfter(true);
	fadeOutAnim.setDuration(1000);
	Animation fadeInAnim = new AlphaAnimation(0.f,relativeDistance);
	fadeInAnim.setFillAfter(true);
	fadeInAnim.setDuration(1000);
	mAlbumCoverHelperLayout.startAnimation(fadeOutAnim);
	mAlbumCoverLayout.startAnimation(fadeInAnim);
	
	// Set new song info
	mSongTitleView.setText(mPlaylist.getCurrentSongInfo().mTitle);
	mSingerView.setText(mPlaylist.getCurrentSongInfo().mSinger);
}
 
Example 9
Source File: Pix.java    From PixImagePicker with Apache License 2.0 5 votes vote down vote up
@Override
public void onLongClick(Img img, View view, int position) {
    if (options.getCount() > 1) {
        Utility.vibe(Pix.this, 50);
        LongSelection = true;
        if ((selectionList.size() == 0) && (mBottomSheetBehavior.getState()
                != BottomSheetBehavior.STATE_EXPANDED)) {
            sendButton.setVisibility(View.VISIBLE);
            Animation anim = new ScaleAnimation(
                    0f, 1f, // Start and end values for the X axis scaling
                    0f, 1f, // Start and end values for the Y axis scaling
                    Animation.RELATIVE_TO_SELF, 0.5f, // Pivot point of X scaling
                    Animation.RELATIVE_TO_SELF, 0.5f); // Pivot point of Y scaling
            anim.setFillAfter(true); // Needed to keep the result of the animation
            anim.setDuration(300);
            sendButton.startAnimation(anim);
        }
        if (selectionList.contains(img)) {
            selectionList.remove(img);
            initaliseadapter.select(false, position);
            mainImageAdapter.select(false, position);
        } else {
            if (options.getCount() <= selectionList.size()) {
                Toast.makeText(Pix.this,
                        String.format(getResources().getString(R.string.selection_limiter_pix),
                                selectionList.size()), Toast.LENGTH_SHORT).show();
                return;
            }
            img.setPosition(position);
            selectionList.add(img);
            initaliseadapter.select(true, position);
            mainImageAdapter.select(true, position);
        }
        selection_check.setVisibility(View.GONE);
        topbar.setBackgroundColor(colorPrimaryDark);
        selection_count.setText(selectionList.size() + " " + getResources().getString(R.string.pix_selected));
        img_count.setText(String.valueOf(selectionList.size()));
        DrawableCompat.setTint(selection_back.getDrawable(), Color.parseColor("#ffffff"));
    }
}
 
Example 10
Source File: ArcLayout.java    From timecat with Apache License 2.0 5 votes vote down vote up
/**
 * 展开动画
 */
private static Animation createExpandAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) {
    Animation animation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 0, 720);
    animation.setStartOffset(startOffset);
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setFillAfter(true);

    return animation;
}
 
Example 11
Source File: RayLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createExpandAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
		long startOffset, long duration, Interpolator interpolator) {
	Animation animation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 0, 720);
	animation.setStartOffset(startOffset);
	animation.setDuration(duration);
	animation.setInterpolator(interpolator);
	animation.setFillAfter(true);

	return animation;
}
 
Example 12
Source File: PaymentRequestSection.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    Animation out = new AlphaAnimation(mUpdatedView.getAlpha(), 0.0f);
    out.setDuration(UPDATE_TEXT_ANIMATION_DURATION_MS);
    out.setInterpolator(new LinearOutSlowInInterpolator());
    out.setFillAfter(true);
    mUpdatedView.startAnimation(out);
}
 
Example 13
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 5 votes vote down vote up
/**
 * For the Card Views
 */
public static void startAlphaRevealAnimation(int delay, final View VIEW, boolean includeTransition) {
    final int ANIMATION_DURATION = 300;

    final Animation mAlphaAnimation = new AlphaAnimation(0f, 1f);
    mAlphaAnimation.setDuration(ANIMATION_DURATION);
    mAlphaAnimation.setFillAfter(true);

    final AnimationSet mRevealAnimations = new AnimationSet(true);
    mRevealAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
    mRevealAnimations.addAnimation(mAlphaAnimation);
    mRevealAnimations.setFillAfter(true);

    if (includeTransition) {
        final Animation mTransitionAnimation = new TranslateAnimation(0, 0, VIEW.getHeight() / 2, 0);
        mTransitionAnimation.setDuration(ANIMATION_DURATION);
        mTransitionAnimation.setFillAfter(false);

        mRevealAnimations.addAnimation(mTransitionAnimation);
    }

    new Handler().postDelayed(() -> {
        if (VIEW != null)
            VIEW.startAnimation(mRevealAnimations);
    }, delay);

}
 
Example 14
Source File: ArcMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);
    animation.setDuration(100);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}
 
Example 15
Source File: MapWidget.java    From mappwidget with Apache License 2.0 5 votes vote down vote up
private Animation getZoomOutAnimation() {
	float fromX = 2.0f;
	float fromY = 2.0f;
	float toX = 1.0f;
	float toY = 1.0f;
	float pivotX = getWidth() / 2.0f;
	float pivotY = getHeight() / 2.0f;
	Animation zoomOutAnimation = new ScaleAnimation(fromX, toX, fromY, toY,
			pivotX, pivotY);
	zoomOutAnimation.setDuration(500);
	zoomOutAnimation.setInterpolator(decelerateInterpolator);
	zoomOutAnimation.setFillAfter(true);

	return zoomOutAnimation;
}
 
Example 16
Source File: ArcMenu.java    From zone-sdk with MIT License 5 votes vote down vote up
/**
 * 缩小消失
 * @param durationMillis
 * @return
 */
private Animation scaleSmallAnim(int durationMillis)
{
	Animation anim = new ScaleAnimation(1.0f, 0f, 1.0f, 0f,
			Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	anim.setDuration(durationMillis);
	anim.setFillAfter(true);
	return anim;
}
 
Example 17
Source File: IndexView.java    From ListIndex with Apache License 2.0 4 votes vote down vote up
public void init(final ListView listView, final TextView textView) {
	setOrientation(VERTICAL);

	addTextView('#');
	for (int i = 0; i < 26; i++) {
		addTextView((char) ('A' + i));
	}

	final Animation animation = new AlphaAnimation(1, 0);
	animation.setDuration(1500);
	animation.setFillAfter(true);

	final ListAdapter listAdapter = listView.getAdapter();

	setOnTouchListener(new OnTouchListener() {

		@Override
		public boolean onTouch(View v, MotionEvent event) {

			switch (event.getAction()) {
			case MotionEvent.ACTION_DOWN:
			case MotionEvent.ACTION_MOVE:
				int position = (int) (event.getY() * 27 / v.getHeight());
				if (position >= 0 && position <= 26) {
					char c;
					int localPosition;
					if (position == 0) {
						c = '#';
						localPosition = 0;
					} else {
						c = (char) ('A' - 1 + position);
						localPosition = searchPosition(listAdapter, c);
					}
					if (localPosition != -1) {
						listView.setSelection(localPosition);
					}
					textView.setText(String.valueOf(c));
					if (textView.getVisibility() == View.GONE) {
						textView.setVisibility(View.VISIBLE);
					}
					textView.startAnimation(animation);
				} else {
					listView.setSelection(0);
				}
				return true;
			}
			return false;

		}
	});
}
 
Example 18
Source File: CubeSpinner.java    From MillSpinners with Apache License 2.0 4 votes vote down vote up
private void doMainAnimation() {
    for (CubeView cubeView : this.cubeViews) {
        cubeView.clearAnimation();
    }

    this.firstHandler.removeCallbacks(this.firstRunnable);
    this.secondHandler.removeCallbacks(this.secondRunnable);
    this.thirdHandler.removeCallbacks(this.thirdRunnable);
    this.fourthHandler.removeCallbacks(this.fourthRunnable);
    this.fifthHandler.removeCallbacks(this.fifthRunnable);

    final Animation animationBack = new TranslateAnimation(0, this.triangleHeight, 0, this.cubeHalfRadius);
    animationBack.setDuration(this.speedTick);
    animationBack.setFillAfter(true);
    this.cubeViews[0].startAnimation(animationBack);
    this.cubeViews[1].startAnimation(animationBack);
    this.cubeViews[2].startAnimation(animationBack);
    this.cubeViews[9].startAnimation(animationBack);
    this.cubeViews[10].startAnimation(animationBack);
    this.cubeViews[11].startAnimation(animationBack);
    this.cubeViews[18].startAnimation(animationBack);
    this.cubeViews[19].startAnimation(animationBack);
    this.cubeViews[20].startAnimation(animationBack);

    final Animation animationFront = new TranslateAnimation(0, -this.triangleHeight, 0, -this.cubeHalfRadius);
    animationFront.setDuration(this.speedTick);
    animationFront.setFillAfter(true);
    this.cubeViews[6].startAnimation(animationFront);
    this.cubeViews[7].startAnimation(animationFront);
    this.cubeViews[8].startAnimation(animationFront);
    this.cubeViews[15].startAnimation(animationFront);
    this.cubeViews[16].startAnimation(animationFront);
    this.cubeViews[17].startAnimation(animationFront);
    this.cubeViews[24].startAnimation(animationFront);
    this.cubeViews[25].startAnimation(animationFront);
    this.cubeViews[26].startAnimation(animationFront);

    firstHandler.postDelayed(this.firstRunnable, this.speedTick);
    secondHandler.postDelayed(this.secondRunnable, this.speedTick * 2);
    thirdHandler.postDelayed(this.thirdRunnable, this.speedTick * 3);
    fourthHandler.postDelayed(this.fourthRunnable, this.speedTick * 4);
    fifthHandler.postDelayed(this.fifthRunnable, this.speedTick * 5);
}
 
Example 19
Source File: AndroidVsIosHeaderView.java    From youqu_master with Apache License 2.0 4 votes vote down vote up
public AndroidVsIosHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    inflate(context, R.layout.layout_irecyclerview_bat_vs_supper_refresh_header_view, this);
    ivBatMan = (ImageView) findViewById(R.id.ivBatMan);
    ivSuperMan = (ImageView) findViewById(R.id.ivSuperMan);
    ivVs = (ImageView) findViewById(R.id.imageView);

    PropertyValuesHolder translationX1 = PropertyValuesHolder.ofFloat("translationX",0.0f,100.0f,0.0f);
    PropertyValuesHolder rotate = PropertyValuesHolder.ofFloat("rotationY",0.0f,380.0f,0.0f);
    PropertyValuesHolder translationX2 = PropertyValuesHolder.ofFloat("translationX",0.0f,-100.0f,0.0f);

    ObjectAnimator objectAnimator1 = ObjectAnimator.ofPropertyValuesHolder(ivBatMan,  translationX1);
    objectAnimator1.setRepeatCount(ValueAnimator.INFINITE);
    objectAnimator1.setRepeatMode(ValueAnimator.INFINITE);

    ObjectAnimator objectAnimator2 = ObjectAnimator.ofPropertyValuesHolder(ivSuperMan,translationX2);
    objectAnimator2.setRepeatCount(ValueAnimator.INFINITE);
    objectAnimator2.setRepeatMode(ValueAnimator.INFINITE);

    ObjectAnimator objectAnimator3 = ObjectAnimator.ofPropertyValuesHolder(ivVs,  rotate);
    objectAnimator3.setRepeatCount(ValueAnimator.INFINITE);
    objectAnimator3.setRepeatMode(ValueAnimator.INFINITE);

     Animation animation =new RotateAnimation(0f,360f, Animation.RELATIVE_TO_SELF,
            0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    Animation animation1 =new RotateAnimation(0f,-360f, Animation.RELATIVE_TO_SELF,
            0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    animation.setFillAfter(true);
    animation.setDuration(2000);
    animation.setRepeatCount(ValueAnimator.INFINITE);
    animation.setRepeatMode(ValueAnimator.INFINITE);
    animation1.setFillAfter(true);
    animation1.setDuration(2000);
    animation1.setRepeatCount(ValueAnimator.INFINITE);
    animation1.setRepeatMode(ValueAnimator.INFINITE);
    ivBatMan.setAnimation(animation);
    ivSuperMan.setAnimation(animation1);

    btnSexAnimatorSet = new AnimatorSet();
    btnSexAnimatorSet.playTogether(objectAnimator1, objectAnimator2,objectAnimator3);
    btnSexAnimatorSet.setDuration(2000);
    btnSexAnimatorSet.start();

}
 
Example 20
Source File: AnimationUtils.java    From proteus with Apache License 2.0 4 votes vote down vote up
public Animation instantiate(Context c) {
  Animation anim = createAnimation(c);
  if (null != anim) {
    if (null != detachWallpaper) {
      anim.setDetachWallpaper(detachWallpaper);
    }

    if (null != duration) {
      anim.setDuration(duration);
    }

    if (null != fillAfter) {
      anim.setFillAfter(fillAfter);
    }

    if (null != fillBefore) {
      anim.setFillBefore(fillBefore);
    }

    if (null != fillEnabled) {
      anim.setFillEnabled(fillEnabled);
    }

    if (null != interpolator) {
      Interpolator i = loadInterpolator(c, interpolator);
      if (null != i) {
        anim.setInterpolator(i);
      }
    }

    if (null != repeatCount) {
      anim.setRepeatCount(repeatCount);
    }

    if (null != repeatMode) {
      anim.setRepeatMode(repeatMode);
    }

    if (null != startOffset) {
      anim.setStartOffset(startOffset);
    }

    if (null != zAdjustment) {
      anim.setZAdjustment(zAdjustment);
    }
  }
  return anim;
}