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

The following examples show how to use android.view.animation.AlphaAnimation#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: ViewHolder.java    From baseAdapter with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: HomeScreenActivity.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
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;

}
 
Example 3
Source File: PhotoViewer.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
private void toggleOverlayView(boolean show) {
    if (overlayViewVisible == show) {
        return;
    }
    if (currentOverlay.getVisibility() == View.VISIBLE) {
        overlayViewVisible = show;
        if (android.os.Build.VERSION.SDK_INT >= 11) {
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(
                    ObjectAnimator.ofFloat(currentOverlay, "alpha", show ? 1.0f : 0.0f)
            );
            animatorSet.setDuration(200);
            animatorSet.start();
        } else {
            AlphaAnimation animation = new AlphaAnimation(show ? 0.0f : 1.0f, show ? 1.0f : 0.0f);
            animation.setDuration(200);
            animation.setFillAfter(true);
            currentOverlay.startAnimation(animation);
        }
    }
}
 
Example 4
Source File: ViewHolder.java    From baseAdapter with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 5
Source File: RegisterActivity.java    From PracticeCode with Apache License 2.0 6 votes vote down vote up
private void initAnimation() {
    FlyOutAnimation = new TranslateAnimation(0, 0, 0, -1000);
    FlyOutAnimation.setDuration(500);
    FlyOutAnimation.setFillAfter(true);

    FadeInAnimation = new AlphaAnimation(0, 1);
    FadeInAnimation.setDuration(500);
    FadeInAnimation.setFillAfter(true);

    FlyBackAnimation = new TranslateAnimation(0, 0, -1000, 0);
    FlyBackAnimation.setDuration(500);
    FlyBackAnimation.setFillAfter(true);

    FadeOutAnimation = new AlphaAnimation(1, 0);
    FadeOutAnimation.setDuration(500);
    FadeOutAnimation.setFillAfter(true);
}
 
Example 6
Source File: PickerFragment.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
private static void setAlpha(View view, float alpha) {
    // Set the alpha appropriately (setAlpha is API >= 11, this technique works on all API levels).
    AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha);
    alphaAnimation.setDuration(0);
    alphaAnimation.setFillAfter(true);
    view.startAnimation(alphaAnimation);
}
 
Example 7
Source File: ViewUtils.java    From Anagram-Solver with MIT License 5 votes vote down vote up
public static 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);
    }
}
 
Example 8
Source File: BaseViewHolder.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
public BaseViewHolder 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;
}
 
Example 9
Source File: UserActivity.java    From materialup with Apache License 2.0 5 votes vote down vote up
public static void startAlphaAnimation(View v, long duration, int visibility) {
    AlphaAnimation alphaAnimation = (visibility == View.VISIBLE)
            ? new AlphaAnimation(0f, 1f)
            : new AlphaAnimation(1f, 0f);

    alphaAnimation.setDuration(duration);
    alphaAnimation.setFillAfter(true);
    v.startAnimation(alphaAnimation);
}
 
Example 10
Source File: EasyRVHolder.java    From EasyAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public EasyRVHolder 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;
}
 
Example 11
Source File: BaseViewHolder.java    From demo4Fish with MIT License 5 votes vote down vote up
/**
 * Add an action to set the alpha of a view. Can be called multiple times.
 * Alpha between 0-1.
 */
public BaseViewHolder 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;
}
 
Example 12
Source File: EasyRVHolder.java    From BookReader with Apache License 2.0 5 votes vote down vote up
@Override
public EasyRVHolder 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;
}
 
Example 13
Source File: BaseAdapterHelper.java    From base-adapter-helper-recyclerview with Apache License 2.0 5 votes vote down vote up
/**
 * Add an action to set the alpha of a view. Can be called multiple times.
 * Alpha between 0-1.
 */
public BaseAdapterHelper setAlpha(int viewId, float value) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        retrieveView(viewId).setAlpha(value);
    } else {
        // Pre-honeycomb hack to set Alpha value
        AlphaAnimation alpha = new AlphaAnimation(value, value);
        alpha.setDuration(0);
        alpha.setFillAfter(true);
        retrieveView(viewId).startAnimation(alpha);
    }
    return this;
}
 
Example 14
Source File: PostFeedActivity.java    From umeng_community_android with MIT License 5 votes vote down vote up
/**
 * 启动淡出动画</br>
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void startFadeOutAnimForTopicTipView() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (mTopicTipView.getAlpha() < 0.1f) {
            return;
        }
    }

    AlphaAnimation alphaAnimationOut = new AlphaAnimation(1.0f, 0);
    alphaAnimationOut.setDuration(300);
    alphaAnimationOut.setFillAfter(true);
    mTopicTipView.startAnimation(alphaAnimationOut);
}
 
Example 15
Source File: StickyScrollView.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
private void showView(View v) {
	if(Build.VERSION.SDK_INT>=11){
		v.setAlpha(1);
	}else{
		AlphaAnimation anim = new AlphaAnimation(0, 1);
		anim.setDuration(0);
		anim.setFillAfter(true);
		v.startAnimation(anim);
	}
}
 
Example 16
Source File: RecyclerViewHolder.java    From Android-BLE with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
public RecyclerViewHolder 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;
}
 
Example 17
Source File: AnimationUtil.java    From Modularity with Apache License 2.0 5 votes vote down vote up
/**
 * 透明度 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;
}
 
Example 18
Source File: ViewAnimationUtil.java    From SimpleProject with MIT License 4 votes vote down vote up
public static Animation getFadeInAnimation(int duration) {
	AlphaAnimation animation = new AlphaAnimation(0, 1);
	animation.setDuration(duration);
	animation.setFillAfter(true);
	return animation;
}
 
Example 19
Source File: ViewAnimationUtil.java    From SimpleProject with MIT License 4 votes vote down vote up
public static Animation getFadeOutAnimation(int duration) {
	AlphaAnimation animation = new AlphaAnimation(1, 0);
	animation.setDuration(duration);
	animation.setFillAfter(true);
	return animation;
}
 
Example 20
Source File: Utils.java    From DateTimepicker with Apache License 2.0 4 votes vote down vote up
public static void setAlphaForView(View v, float alpha) {
AlphaAnimation animation = new AlphaAnimation(alpha, alpha);
animation.setDuration(0);
animation.setFillAfter(true);
v.startAnimation(animation);
}