Java Code Examples for android.view.animation.ScaleAnimation#RELATIVE_TO_SELF

The following examples show how to use android.view.animation.ScaleAnimation#RELATIVE_TO_SELF . 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: AboutActivity.java    From AndroidPlusJava with GNU General Public License v3.0 6 votes vote down vote up
private void startAnimation() {
    AnimationSet animationSet = new AnimationSet(true);
    RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);

    ScaleAnimation scaleAnimation = new ScaleAnimation(1.5f, 1, 1.5f, 1,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);

    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);

    animationSet.addAnimation(rotateAnimation);
    animationSet.addAnimation(scaleAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(2000);
    mAboutInfo.startAnimation(animationSet);
}
 
Example 2
Source File: RippleImageView.java    From RippleImageView with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化动画集
 * @return
 */
private AnimationSet initAnimationSet() {
    AnimationSet as = new AnimationSet(true);
    //缩放度:变大两倍
    ScaleAnimation sa = new ScaleAnimation(1f, 2f, 1f, 2f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    sa.setDuration(show_spacing_time * 3);
    sa.setRepeatCount(Animation.INFINITE);// 设置循环
    //透明度
    AlphaAnimation aa = new AlphaAnimation(1, 0.1f);
    aa.setDuration(show_spacing_time * 3);
    aa.setRepeatCount(Animation.INFINITE);//设置循环
    as.addAnimation(sa);
    as.addAnimation(aa);
    return as;
}
 
Example 3
Source File: AnimationUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个中心点缩放动画
 * @param fromX             动画开始前在 X 坐标
 * @param toX               动画结束后在 X 坐标
 * @param fromY             动画开始前在 Y 坐标
 * @param toY               动画结束后在 Y 坐标
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个中心点缩放动画
 */
public static ScaleAnimation getScaleAnimationCenter(final float fromX, final float toX, final float fromY, final float toY,
                                                     final long durationMillis, final AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(fromX, toX, fromY, toY,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        scaleAnimation.setAnimationListener(animationListener);
    }
    return scaleAnimation;
}
 
Example 4
Source File: AnimationUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个缩小动画
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个缩小动画
 */
public static ScaleAnimation getLessenScaleAnimation(final long durationMillis, final AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f,
            ScaleAnimation.RELATIVE_TO_SELF, ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        scaleAnimation.setAnimationListener(animationListener);
    }
    return scaleAnimation;
}
 
Example 5
Source File: AnimationUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个放大动画
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个放大动画
 */
public static ScaleAnimation getAmplificationAnimation(final long durationMillis, final AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
            ScaleAnimation.RELATIVE_TO_SELF, ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        scaleAnimation.setAnimationListener(animationListener);
    }
    return scaleAnimation;
}
 
Example 6
Source File: AnimationUtils.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个缩小动画
 *
 * @param durationMillis    时间
 * @param animationListener 监听
 * @return 一个缩小动画
 */
public static ScaleAnimation getLessenScaleAnimation(long durationMillis, Animation.AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f,
            0.0f, ScaleAnimation.RELATIVE_TO_SELF,
            ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);

    return scaleAnimation;
}
 
Example 7
Source File: AnimationUtils.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个放大动画
 *
 * @param durationMillis    时间
 * @param animationListener 监听
 * @return 返回一个放大的效果
 */
public static ScaleAnimation getAmplificationAnimation(long durationMillis, Animation.AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f,
            1.0f, ScaleAnimation.RELATIVE_TO_SELF,
            ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);
    return scaleAnimation;
}
 
Example 8
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public void scaleAnim_java(View view) {
	// 2.����һ��ScaleAnimation����
	ScaleAnimation animation = new ScaleAnimation(1f, 3f, 1f, 3f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
	// ����ʱ��
	animation.setDuration(1000);
	// ����ֹͣ�����һ֡
	animation.setFillAfter(true);
	// 3.���Ŷ���
	iv_rocket.startAnimation(animation);

}
 
Example 9
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public void setAnim_java(View view) {
	// 2.����һ��AnimationSet
	AnimationSet set = new AnimationSet(true);
	// 3.������������:ƽ�ơ���ת�����š�͸��
			// 2.����TranslateAnimation
	TranslateAnimation trans = new TranslateAnimation(
			TranslateAnimation.RELATIVE_TO_PARENT, 0,
			TranslateAnimation.RELATIVE_TO_PARENT, 0,
			TranslateAnimation.RELATIVE_TO_PARENT, 0,
			TranslateAnimation.RELATIVE_TO_PARENT, -1f);
	// 2.����ScaleAnimation
	ScaleAnimation scale = new ScaleAnimation(1f, 0.6f, 1f, 0.6f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
	// 4.ͨ��set.addAnimtion()
	set.addAnimation(trans);
	set.addAnimation(scale);
	// ��ֵ��
	set.setInterpolator(new AccelerateInterpolator());
	// ����ʱ��
	set.setDuration(2000);
	// ����ֹͣ�����
	set.setFillAfter(true);
	// 5.���Ŷ���
	iv_rocket.startAnimation(set);

}
 
Example 10
Source File: CustomAnim.java    From Utils with Apache License 2.0 5 votes vote down vote up
/**
 * get a lessen scale animation
 *
 * @param durationMillis Duration in milliseconds
 * @param listener       the animation listener to be notified
 * @return An animation that controls the lessen scale of an object
 */
public static ScaleAnimation getLessenScaleAnimation(long durationMillis, Animation.AnimationListener listener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f,
            0.0f, ScaleAnimation.RELATIVE_TO_SELF,
            ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(listener);
    return scaleAnimation;
}
 
Example 11
Source File: CustomAnim.java    From Utils with Apache License 2.0 5 votes vote down vote up
/**
 * get a amplification scale animation
 *
 * @param durationMillis Duration in milliseconds
 * @param listener       the animation listener to be notified
 * @return An animation that controls the amplification scale of an object
 */
public static ScaleAnimation getAmplificationAnimation(long durationMillis, Animation.AnimationListener listener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f,
            1.0f, ScaleAnimation.RELATIVE_TO_SELF,
            ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(listener);
    return scaleAnimation;
}
 
Example 12
Source File: AnimationUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 获取一个缩小动画
 *
 * @param durationMillis
 * @param animationListener
 * @return
 */
public static ScaleAnimation getLessenScaleAnimation(long durationMillis, AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, ScaleAnimation.RELATIVE_TO_SELF, ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);
    return scaleAnimation;
}
 
Example 13
Source File: AnimationUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 获取一个放大动画
 *
 * @param durationMillis
 * @param animationListener
 * @return
 */
public static ScaleAnimation getAmplificationAnimation(long durationMillis, AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, ScaleAnimation.RELATIVE_TO_SELF, ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);
    return scaleAnimation;
}
 
Example 14
Source File: NMapCalloutOverlayView.java    From maps.android with Apache License 2.0 3 votes vote down vote up
private void animateCallout() {

		// Create a scale animation
		ScaleAnimation animation = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
			ScaleAnimation.RELATIVE_TO_SELF, 1.0f);

		animation.setDuration(SCALE_DURATION_MILLS);

		this.startAnimation(animation);
	}