类android.view.animation.AlphaAnimation源码实例Demo

下面列出了怎么用android.view.animation.AlphaAnimation的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: scene   文件: AnimatorUtilityTests.java
@Test
public void testResetViewStatus() {
    ActivityController<NavigationSourceUtility.TestActivity> controller = Robolectric.buildActivity(NavigationSourceUtility.TestActivity.class).create().start().resume();
    NavigationSourceUtility.TestActivity testActivity = controller.get();
    View view = new View(testActivity);
    view.setTranslationX(1);
    view.setTranslationY(1);
    view.setScaleX(2.0f);
    view.setScaleY(2.0f);
    view.setRotation(1.0f);
    view.setRotationX(1.0f);
    view.setRotationY(1.0f);
    view.setAlpha(0.5f);
    view.startAnimation(new AlphaAnimation(0.0f, 1.0f));

    AnimatorUtility.resetViewStatus(view);
    assertEquals(0.0f, view.getTranslationX(), 0.0f);
    assertEquals(0.0f, view.getTranslationY(), 0.0f);
    assertEquals(1.0f, view.getScaleX(), 0.0f);
    assertEquals(1.0f, view.getScaleY(), 0.0f);
    assertEquals(0.0f, view.getRotation(), 0.0f);
    assertEquals(0.0f, view.getRotationX(), 0.0f);
    assertEquals(0.0f, view.getRotationY(), 0.0f);
    assertEquals(1.0f, view.getAlpha(), 0.0f);
    assertNull(view.getAnimation());
}
 
源代码2 项目: HomeGenie-Android   文件: StartActivity.java
public void showLogo() {
    _isLogoVisible = true;
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Animation fadeIn = new AlphaAnimation(0, 0.8f);
            fadeIn.setInterpolator(new AccelerateInterpolator()); //and this
            fadeIn.setStartOffset(0);
            fadeIn.setDuration(500);
            //
            AnimationSet animation = new AnimationSet(false); //change to false
            animation.addAnimation(fadeIn);
            animation.setFillAfter(true);
            RelativeLayout ivLogo = (RelativeLayout) findViewById(R.id.logo);
            ivLogo.startAnimation(animation);
        }
    });
}
 
源代码3 项目: OpenEyes   文件: ViewHolder.java
/**
 * 设置透明度
 * @param viewId
 * @param value
 * @return
 */
@SuppressLint("NewApi")
public ViewHolder setAlpha(int viewId, float value)
{
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
    {
        getView(viewId).setAlpha(value);
    } else
    {
        // Pre-honeycomb hack to set Alpha value
        AlphaAnimation alpha = new AlphaAnimation(value, value);
        alpha.setDuration(0);
        alpha.setFillAfter(true);
        getView(viewId).startAnimation(alpha);
    }
    return this;
}
 
private AnimationSet getEntryAnimation(int inAnimationDuration) {
    //In
    AnimationSet mInAnimationSet = new AnimationSet(false);

    TranslateAnimation mSlideInAnimation = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_SELF, -1.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    mSlideInAnimation.setFillAfter(true);

    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mFadeInAnimation.setFillAfter(true);

    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);

    mInAnimationSet.setDuration(inAnimationDuration);

    return mInAnimationSet;

}
 
源代码5 项目: Paginize   文件: ZoomPageAnimator.java
private void initAnimations() {
  Animation inScaleAnimation = new ScaleAnimation( 1.2f, 1, 1.2f, 1,
      Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  Animation inAlphaAnimation = new AlphaAnimation(0.0f, 1f);
  AnimationSet inAnimationSet = new AnimationSet(true);
  inAnimationSet.setDuration(ANIMATION_DURATION);
  inAnimationSet.addAnimation(inScaleAnimation);
  inAnimationSet.addAnimation(inAlphaAnimation);
  mInAnimation = inAnimationSet;

  Animation outScaleAnimation = new ScaleAnimation(1, 1.4f, 1, 1.4f,
      Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  Animation outAlphaAnimation = new AlphaAnimation(1f, 0f);
  AnimationSet outAnimationSet = new AnimationSet(true);
  outAnimationSet.setDuration(ANIMATION_DURATION);
  outAnimationSet.addAnimation(outScaleAnimation);
  outAnimationSet.addAnimation(outAlphaAnimation);
  mOutAnimation = outAnimationSet;
}
 
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);
}
 
源代码7 项目: YMenuView   文件: TreeYMenu.java
@Override
public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) {

    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation= new TranslateAnimation(
            0
            ,getYMenuButton().getX() - optionButton.getX()
            ,0
            ,getYMenuButton().getY() - optionButton.getY()
    );
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());

    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(alphaAnimation);
    //设置动画延时
    animationSet.setStartOffset(60*(getOptionPositionCount() - index));
    return animationSet;
}
 
源代码8 项目: HomeGenie-Android   文件: StartActivity.java
public void hideLogo() {
    _isLogoVisible = false;
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Animation fadeOut = new AlphaAnimation(0.8f, 0);
            fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
            fadeOut.setStartOffset(0);
            fadeOut.setDuration(500);
            //
            AnimationSet animation = new AnimationSet(false); //change to false
            animation.addAnimation(fadeOut);
            animation.setFillAfter(true);
            RelativeLayout ivLogo = (RelativeLayout) findViewById(R.id.logo);
            ivLogo.startAnimation(animation);
        }
    });
}
 
源代码9 项目: mobile-sdk-android   文件: Reveal.java
private void setOutAnimation(float[] direction, Interpolator interpolator, long duration) {
    Animation push = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, direction[0], Animation.RELATIVE_TO_PARENT, direction[1],
            Animation.RELATIVE_TO_PARENT, direction[2], Animation.RELATIVE_TO_PARENT, direction[3]
    );
    push.setInterpolator(interpolator);
    push.setDuration(duration);

    Animation fade = new AlphaAnimation(1, 0);
    fade.setDuration(duration);
    fade.setInterpolator(interpolator);

    AnimationSet set = new AnimationSet(false);
    set.addAnimation(push);
    set.addAnimation(fade);

    outAnimation = set;
}
 
源代码10 项目: candybar   文件: FadeInBitmapDisplayer.java
/**
 * Animates {@link ImageView} with "fade-in" effect
 *
 * @param imageView      {@link ImageView} which display image in
 * @param durationMillis The length of the animation in milliseconds
 */
public static void animate(View imageView, int durationMillis) {
    if (imageView != null) {
        AlphaAnimation fadeImage = new AlphaAnimation(0, 1);
        fadeImage.setDuration(durationMillis);
        fadeImage.setInterpolator(new DecelerateInterpolator());
        imageView.startAnimation(fadeImage);
    }
}
 
源代码11 项目: Pharmacy-Android   文件: OrdersAdapter.java
private void fadeOnAck(@Order.Status String status, View view) {

        clearAnimation(view);

        if (status.equals(ACKNOWLEDGED)) {

            AlphaAnimation alphaAnimation = new AlphaAnimation(0.3f, 0.9f);
            alphaAnimation.setDuration(700);
            alphaAnimation.setRepeatMode(Animation.REVERSE);
            alphaAnimation.setRepeatCount(Animation.INFINITE);
            view.setAnimation(alphaAnimation);
            alphaAnimation.start();



            // color animation
/*        ObjectAnimator slide = ObjectAnimator.ofObject(view,
                "backgroundColor",
                new ArgbEvaluator(),
                ContextCompat.getColor(App.getContext(), R.color.white),
                ContextCompat.getColor(App.getContext(), R.color.md_deep_orange_50));*/

            /*     ObjectAnimator slide = ObjectAnimator.ofFloat(view,
                    "alpha", 0.3f, 0.9f);
            slide.setInterpolator(new AccelerateDecelerateInterpolator());
            slide.setDuration(700);
            slide.setRepeatCount(ValueAnimator.INFINITE);
            slide.setRepeatMode(ValueAnimator.REVERSE);
            slide.start();*/
        }
    }
 
源代码12 项目: bither-android   文件: SensorVisualizerView.java
public void onSensorData(final Sensor sensor) {
    if (animatingSensors.contains(sensor.getType()) || holdingBackNextFlash) {
        return;
    }
    holdingBackNextFlash = true;
    
    postDelayed(new Runnable() {
        @Override
        public void run() {
            holdingBackNextFlash = false;
        }
    }, FlashDuration / 2);

    post(new Runnable() {
        @Override
        public void run() {
            Integer id = ViewIds.get(sensor.getType());
            if (id == null) {
                return;
            }
            View v = findViewById(id);
            if (v == null) {
                return;
            }
            animatingSensors.add(sensor.getType());
            AlphaAnimation fadeIn = new AlphaAnimation(FadeAlpha, FlashAlpha);
            fadeIn.setDuration(FlashDuration);
            AlphaAnimation fadeOut = new AlphaAnimation(FlashAlpha, FadeAlpha);
            fadeOut.setDuration(FlashDuration);
            fadeOut.setStartOffset(fadeIn.getDuration() + FlashDuration / 2);
            AnimationSet set = new AnimationSet(false);
            set.addAnimation(fadeIn);
            set.addAnimation(fadeOut);
            set.setAnimationListener(new FadeAnimListener(sensor.getType()));
            set.setFillAfter(true);
            v.startAnimation(set);
        }
    });
}
 
源代码13 项目: KJFrameForAndroid   文件: KJAnimations.java
/**
 * 透明度 Alpha
 */
public static Animation getAlphaAnimation(float fromAlpha, float toAlpha,
        long durationMillis) {
    AlphaAnimation alpha = new AlphaAnimation(fromAlpha, toAlpha);
    alpha.setDuration(durationMillis);
    alpha.setFillAfter(true);
    return alpha;
}
 
private void setAlpha(View view, float alpha, long durationMillis) {
    if (Build.VERSION.SDK_INT < 11) {
        final AlphaAnimation animation = new AlphaAnimation(alpha, alpha);
        animation.setDuration(durationMillis);
        animation.setFillAfter(true);
        view.startAnimation(animation);
    } else {
        view.setAlpha(alpha);
    }
}
 
源代码15 项目: VIA-AI   文件: LoadingWrapper.java
/**
 @brief Hide the wrapper.
 */
public void hide()
{
    mUI_LoadingProgress.stop();
    AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f);
    anim.setDuration(1000);
    anim.setRepeatCount(0);
    this.startAnimation(anim);
    this.setVisibility(View.INVISIBLE);
}
 
/**
 * Animates {@link ImageView} with "fade-in" effect
 *
 * @param imageView      {@link ImageView} which display image in
 * @param durationMillis The length of the animation in milliseconds
 */
public static void animate(View imageView, int durationMillis) {
	if (imageView != null) {
		AlphaAnimation fadeImage = new AlphaAnimation(0, 1);
		fadeImage.setDuration(durationMillis);
		fadeImage.setInterpolator(new DecelerateInterpolator());
		imageView.startAnimation(fadeImage);
	}
}
 
源代码17 项目: star-zone-android   文件: AnimUtils.java
public static AlphaAnimation getAlphaAnimation(float start, float end, long durationMillis) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(start, end);
    alphaAnimation.setDuration(durationMillis);
    alphaAnimation.setFillEnabled(true);
    alphaAnimation.setFillAfter(true);
    return alphaAnimation;
}
 
源代码18 项目: Android-Notification   文件: AnimationFactory.java
/**
 * Create push down animation for entering.
 *
 * @return Animation
 */
public static Animation pushDownIn() {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.setFillAfter(true);
    animationSet.addAnimation(new TranslateAnimation(0, 0, -100, 0));
    animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f));
    return animationSet;
}
 
源代码19 项目: star-zone-android   文件: PopupProgress.java
@Override
protected Animation initExitAnimation() {
    AlphaAnimation alphaAnimation = new AlphaAnimation(1.0F, 0.0F);
    alphaAnimation.setDuration(300L);
    alphaAnimation.setInterpolator(new AccelerateInterpolator());
    return alphaAnimation;
}
 
源代码20 项目: adt-leanback-support   文件: FragmentManager.java
static Animation makeOpenCloseAnimation(Context context, float startScale,
        float endScale, float startAlpha, float endAlpha) {
    AnimationSet set = new AnimationSet(false);
    ScaleAnimation scale = new ScaleAnimation(startScale, endScale, startScale, endScale,
            Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    scale.setInterpolator(DECELERATE_QUINT);
    scale.setDuration(ANIM_DUR);
    set.addAnimation(scale);
    AlphaAnimation alpha = new AlphaAnimation(startAlpha, endAlpha);
    alpha.setInterpolator(DECELERATE_CUBIC);
    alpha.setDuration(ANIM_DUR);
    set.addAnimation(alpha);
    return set;
}
 
源代码21 项目: YuanNewsForAndroid   文件: AnimationLoader.java
public static AnimationSet getOutAnimation(Context context) {
    AnimationSet out = new AnimationSet(context, null);
    AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
    alpha.setDuration(150);
    ScaleAnimation scale = new ScaleAnimation(1.0f, 0.6f, 1.0f, 0.6f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale.setDuration(150);
    out.addAnimation(alpha);
    out.addAnimation(scale);
    return out;
}
 
源代码22 项目: ShowCaseView   文件: GuideView.java
public void show() {
    this.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    this.setClickable(false);

    ((ViewGroup) ((Activity) getContext()).getWindow().getDecorView()).addView(this);
    AlphaAnimation startAnimation = new AlphaAnimation(0.0f, 1.0f);
    startAnimation.setDuration(APPEARING_ANIMATION_DURATION);
    startAnimation.setFillAfter(true);
    this.startAnimation(startAnimation);
    mIsShowing = true;
}
 
源代码23 项目: zen4android   文件: IcsProgressBar.java
/**
 * <p>
 * Initialize the progress bar's default values:
 * </p>
 * <ul>
 * <li>progress = 0</li>
 * <li>max = 100</li>
 * <li>animation duration = 4000 ms</li>
 * <li>indeterminate = false</li>
 * <li>behavior = repeat</li>
 * </ul>
 */
private void initProgressBar() {
    mMax = 100;
    mProgress = 0;
    mSecondaryProgress = 0;
    mIndeterminate = false;
    mOnlyIndeterminate = false;
    mDuration = 4000;
    mBehavior = AlphaAnimation.RESTART;
    mMinWidth = 24;
    mMaxWidth = 48;
    mMinHeight = 24;
    mMaxHeight = 48;
}
 
源代码24 项目: barterli_android   文件: AnimateImageView.java
private void init(Context context, AttributeSet attrs) {

        if(attrs == null) {
            initializeWithDefaults();
        } else {
            TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.AnimateImageView);

            if(attributes == null) {
                initializeWithDefaults();
            }

            else {
                mShouldAnimateChanges = attributes.getBoolean(R.styleable.AnimateImageView_animate_changes, false);
                int inAnimationResId = attributes.getResourceId(R.styleable.AnimateImageView_in_animation, 0);
                int outAnimationResId = attributes.getResourceId(R.styleable.AnimateImageView_out_animation, 0);
                attributes.recycle();

                if(inAnimationResId == 0) {
                    mInAnimation = new AlphaAnimation(0.0f, 1.0f);
                    mInAnimation.setDuration(400);
                    mInAnimation.setFillAfter(true);
                } else {
                    mInAnimation = AnimationUtils.loadAnimation(context, inAnimationResId);
                }

                if(outAnimationResId == 0) {
                    mOutAnimation = new AlphaAnimation(1.0f, 0.0f);
                    mOutAnimation.setDuration(150);
                    mOutAnimation.setFillAfter(true);
                } else {
                    mOutAnimation = AnimationUtils.loadAnimation(context, outAnimationResId);
                }

                mInAnimation.setAnimationListener(this);
                mOutAnimation.setAnimationListener(this);
            }
        }
    }
 
源代码25 项目: PianoTiles   文件: CountDownView.java
private void initAnim() {
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    ScaleAnimation scaleAnim = new ScaleAnimation(1,2,1,2, Animation.RELATIVE_TO_SELF,0.5f,
            Animation.RELATIVE_TO_SELF,0.5f);
    mAnimationSet = new AnimationSet(true);
    mAnimationSet.addAnimation(alphaAnimation);
    mAnimationSet.addAnimation(scaleAnim);
    mAnimationSet.setDuration(DURATION);
}
 
源代码26 项目: RecordView   文件: AnimationHelper.java
public void animateSmallMicAlpha() {
    alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(500);
    alphaAnimation.setRepeatMode(Animation.REVERSE);
    alphaAnimation.setRepeatCount(Animation.INFINITE);
    smallBlinkingMic.startAnimation(alphaAnimation);
}
 
源代码27 项目: android-project-wo2b   文件: BadgeView.java
private void init(Context context, View target, int tabIndex)
{

	this.context = context;
	this.target = target;
	this.targetTabIndex = tabIndex;

	// apply defaults
	badgePosition = DEFAULT_POSITION;
	badgeMarginH = dipToPixels(DEFAULT_MARGIN_DIP);
	badgeMarginV = badgeMarginH;
	badgeColor = DEFAULT_BADGE_COLOR;

	setTypeface(Typeface.DEFAULT_BOLD);
	int paddingPixels = dipToPixels(DEFAULT_LR_PADDING_DIP);
	setPadding(paddingPixels, 0, paddingPixels, 0);
	setTextColor(DEFAULT_TEXT_COLOR);

	fadeIn = new AlphaAnimation(0, 1);
	fadeIn.setInterpolator(new DecelerateInterpolator());
	fadeIn.setDuration(200);

	fadeOut = new AlphaAnimation(1, 0);
	fadeOut.setInterpolator(new AccelerateInterpolator());
	fadeOut.setDuration(200);

	isShown = false;

	if (this.target != null)
	{
		applyTo(this.target);
	}
	else
	{
		show();
	}

}
 
源代码28 项目: BookReader   文件: EasyLVHolder.java
@Override
public EasyLVHolder setAlpha(int viewId, float value) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getView(viewId).setAlpha(value);
    } else {
        AlphaAnimation alpha = new AlphaAnimation(value, value);
        alpha.setDuration(0);
        alpha.setFillAfter(true);
        getView(viewId).startAnimation(alpha);
    }
    return this;
}
 
源代码29 项目: WliveTV   文件: FadeInBitmapDisplayer.java
/**
 * Animates {@link ImageView} with "fade-in" effect
 *
 * @param imageView      {@link ImageView} which display image in
 * @param durationMillis The length of the animation in milliseconds
 */
public static void animate(View imageView, int durationMillis) {
	if (imageView != null) {
		AlphaAnimation fadeImage = new AlphaAnimation(0, 1);
		fadeImage.setDuration(durationMillis);
		fadeImage.setInterpolator(new DecelerateInterpolator());
		imageView.startAnimation(fadeImage);
	}
}
 
private void setup(@NonNull View bubble) {
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(DURATION);
    addAnimation(alphaAnimation);

    setAnimationListener(new BubbleVisibilityAnimationListener(bubble, toVisible));

    //Works around the issue of the animation never starting because the view is GONE
    if (bubble.getVisibility() == View.GONE) {
        bubble.setVisibility(View.INVISIBLE);
    }
}