android.view.animation.Animation#startNow()源码实例Demo

下面列出了android.view.animation.Animation#startNow() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AndroidDemoProjects   文件: SlothActivity.java
@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {
    super.onSizeChanged(width, height, oldw, oldh);
    Random random = new Random();
    Interpolator interpolator = new LinearInterpolator();

    money_count = Math.max(width, height) / 30;
    coords = new int[money_count][];
    drawables.clear();
    for (int i = 0; i < money_count; i++) {
        Animation animation = new TranslateAnimation(0, height / 10
                - random.nextInt(height / 5), 0, height + 30);
        animation.setDuration(10 * height + random.nextInt(5 * height));
        animation.setRepeatCount(-1);
        animation.initialize(10, 10, 10, 10);
        animation.setInterpolator(interpolator);

        coords[i] = new int[] { random.nextInt(width - 30), -80 };

        drawables.add(new AnimateDrawable(money_sign, animation));
        animation.setStartOffset(random.nextInt(20 * height));
        animation.startNow();
    }
}
 
源代码2 项目: codeexamples-android   文件: AnimateDrawables.java
public SampleView(Context context) {
    super(context);
    setFocusable(true);
    setFocusableInTouchMode(true);

    Drawable dr = context.getResources().getDrawable(R.drawable.beach);
    dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());

    Animation an = new TranslateAnimation(0, 100, 0, 200);
    an.setDuration(2000);
    an.setRepeatCount(-1);
    an.initialize(10, 10, 10, 10);

    mDrawable = new AnimateDrawable(dr, an);
    an.startNow();
}
 
源代码3 项目: ripple   文件: AnimationHelpers.java
static void addAnimation(View view, Animation animation, boolean first) {
    Animation previousAnimation = view.getAnimation();
    if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) {
        if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME)
            view.startAnimation(animation);
        else
            view.setAnimation(animation);
        return;
    }

    if (!(previousAnimation instanceof AnimationSet)) {
        AnimationSet newSet = new AnimationSet(false);
        newSet.addAnimation(previousAnimation);
        previousAnimation = newSet;
    }

    // Remove old of same type
    //
    AnimationSet set = (AnimationSet) previousAnimation;
    for (int i = 0; i < set.getAnimations().size(); i++) {
        Animation anim = set.getAnimations().get(i);
        if (anim.getClass() == animation.getClass()) {
            set.getAnimations().remove(i);
            break;
        }
    }

    // Add this (first if it is a scale animation ,else at end)
    if (animation instanceof ScaleAnimation || first) {
        set.getAnimations().add(0, animation);
    } else {
        set.getAnimations().add(animation);
    }

    animation.startNow();
    view.setAnimation(set);
}
 
源代码4 项目: CameraV   文件: UIHelpers.java
public static void addAnimation(View view, Animation animation, boolean first)
{
	Animation previousAnimation = view.getAnimation();
	if (previousAnimation == null || previousAnimation.getClass() == animation.getClass())
	{
		view.startAnimation(animation);
		return;
	}

	if (!(previousAnimation instanceof AnimationSet))
	{
		AnimationSet newSet = new AnimationSet(false);
		newSet.addAnimation(previousAnimation);
		previousAnimation = newSet;
	}

	// Remove old of same type
	//
	AnimationSet set = (AnimationSet) previousAnimation;
	for (int i = 0; i < set.getAnimations().size(); i++)
	{
		Animation anim = set.getAnimations().get(i);
		if (anim.getClass() == animation.getClass())
		{
			set.getAnimations().remove(i);
			break;
		}
	}

	// Add this (first if it is a scale animation ,else at end)
	if (animation instanceof ScaleAnimation || first)
	{
		set.getAnimations().add(0, animation);
	}
	else
	{
		set.getAnimations().add(animation);
	}

	animation.startNow();
	view.setAnimation(set);
}