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

The following examples show how to use android.view.animation.AlphaAnimation#setDuration() . 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: ChannelDetailBSDFragment.java    From zap-android with MIT License 6 votes vote down vote up
private void switchToProgressScreen() {
    mProgressScreen.setVisibility(View.VISIBLE);
    mCloseChannelButton.setEnabled(false);

    // Animate out
    AlphaAnimation animateOut = new AlphaAnimation(1.0f, 0f);
    animateOut.setDuration(200);
    animateOut.setFillAfter(true);

    mContentLayout.startAnimation(animateOut);
    mIvBsdIcon.startAnimation(animateOut);

    // Set size of progress result icon to 0
    mProgressResultIcon.setScaleX(0);
    mProgressResultIcon.setScaleY(0);

    // Animate in
    mProgressScreen.setAlpha(1.0f);
    AlphaAnimation animateIn = new AlphaAnimation(0f, 1.0f);
    animateIn.setDuration(200);
    animateIn.setStartOffset(200);
    animateIn.setFillAfter(true);

    mProgressScreen.startAnimation(animateIn);
}
 
Example 2
Source File: CardboardOverlayView.java    From Cardboard with Apache License 2.0 6 votes vote down vote up
public CardboardOverlayView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOrientation(HORIZONTAL);

    LayoutParams params = new LayoutParams(
        LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);
    params.setMargins(0, 0, 0, 0);

    mLeftView = new CardboardOverlayEyeView(context, attrs);
    mLeftView.setLayoutParams(params);
    addView(mLeftView);

    mRightView = new CardboardOverlayEyeView(context, attrs);
    mRightView.setLayoutParams(params);
    addView(mRightView);

    // Set some reasonable defaults.
    setDepthOffset(0.016f);
    setColor(Color.rgb(150, 255, 180));
    setVisibility(View.VISIBLE);

    mTextFadeAnimation = new AlphaAnimation(1.0f, 0.0f);
    mTextFadeAnimation.setDuration(5000);
}
 
Example 3
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 4
Source File: BadgeView.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
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();
        }

    }
 
Example 5
Source File: ViewHolder.java    From all-base-adapter with Apache License 2.0 5 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 6
Source File: MainActivity.java    From WanDaoJiaIndex with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void setViewAlpha(View v, float alpha){
	if(android.os.Build.VERSION.SDK_INT >= 11){
		v.setAlpha(alpha);
	}else{
		AlphaAnimation alphaAnim = new AlphaAnimation(alpha, alpha);
		alphaAnim.setDuration(0);
		alphaAnim.setFillAfter(true);
		v.startAnimation(alphaAnim);
	}
}
 
Example 7
Source File: BadgeView.java    From android-common-utils with Apache License 2.0 5 votes vote down vote up
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();
	}
	
}
 
Example 8
Source File: PickerFragment.java    From Klyph 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 9
Source File: FadeInImageDisplayer.java    From sketch with Apache License 2.0 5 votes vote down vote up
@Override
public void display(@NonNull SketchView sketchView, @NonNull Drawable newDrawable) {
    AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setDuration(duration);
    sketchView.clearAnimation();
    sketchView.setImageDrawable(newDrawable);
    sketchView.startAnimation(animation);
}
 
Example 10
Source File: FadeInBitmapDisplayer.java    From candybar with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 11
Source File: FragmentManager.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
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;
}
 
Example 12
Source File: AlertView.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
private void initAnimations() {
  fadeOut = new AlphaAnimation(1, 0);
  fadeOut.setInterpolator(new AccelerateInterpolator());
  fadeOut.setDuration(300);
  slideDownTop = AnimationUtils.loadAnimation(getContext(), R.anim.slide_down_top);
  slideDownTop.setInterpolator(new OvershootInterpolator(2.0f));
}
 
Example 13
Source File: SplashActivity.java    From LQRWeChat with MIT License 5 votes vote down vote up
@Override
public void initView() {

    StatusBarUtil.setColor(this, UIUtils.getColor(R.color.black));

    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
    alphaAnimation.setDuration(1000);
    mRlButton.startAnimation(alphaAnimation);
}
 
Example 14
Source File: PickerFragment.java    From KlyphMessenger 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 15
Source File: DSListView.java    From direct-select-android with MIT License 5 votes vote down vote up
private void hideListView() {
    if (!readyToHide || animationInProgress || scrollInProgress || !listViewIsShown || adapter == null) return;

    readyToHide = false;
    animationInProgress = true;
    listView.setEnabled(false);

    this.setVisibility(View.INVISIBLE);

    this.pickerBox.onSelect(adapter.getItem(selectedItem), selectedItem);

    AlphaAnimation hideAnimation = new AlphaAnimation(1f, 0f);
    hideAnimation.setStartOffset(subScrollDuration);
    hideAnimation.setDuration(200);
    hideAnimation.setInterpolator(new DecelerateInterpolator());
    hideAnimation.setAnimationListener(new AnimationListenerAdapter() {
        @Override
        public void onAnimationEnd(Animation animation) {
            listViewIsShown = false;
            animationInProgress = false;
        }
    });
    DSListView.this.startAnimation(hideAnimation);

    // Scale picker box text animation if animations enabled
    if (selectorAnimationsEnabled && null != this.pickerBox) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1f + scaleFactorDelta, 1f, 1f + scaleFactorDelta, 1f,
                Animation.RELATIVE_TO_SELF, selectorAnimationCenterPivot ? 0.5f : 0f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setInterpolator(new DecelerateInterpolator());
        scaleAnimation.setStartOffset(100 + subScrollDuration);
        scaleAnimation.setDuration(100);
        scaleAnimation.setFillAfter(true);
        this.pickerBox.getCellRoot().startAnimation(scaleAnimation);
    }
}
 
Example 16
Source File: FragmentManager.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
static Animation makeFadeAnimation(Context context, float start, float end) {
    AlphaAnimation anim = new AlphaAnimation(start, end);
    anim.setInterpolator(DECELERATE_CUBIC);
    anim.setDuration(ANIM_DUR);
    return anim;
}
 
Example 17
Source File: SamplePeopleFragment.java    From android-DecoView-charting with Apache License 2.0 4 votes vote down vote up
private void showAvatar(boolean show, View view) {
    AlphaAnimation animation = new AlphaAnimation(show ? 0.0f : 1.0f, show ? 1.0f : 0.0f);
    animation.setDuration(1000);
    animation.setFillAfter(true);
    view.startAnimation(animation);
}
 
Example 18
Source File: Fade.java    From KSnack with Apache License 2.0 4 votes vote down vote up
public static Animation getAnimation(long millisecond, Interpolator interpolator){
    animation = new AlphaAnimation(0, 1);
    animation.setDuration(millisecond);
    animation.setInterpolator(interpolator);
    return animation;
}
 
Example 19
Source File: FragmentManager.java    From guideshow with MIT License 4 votes vote down vote up
static Animation makeFadeAnimation(Context context, float start, float end) {
    AlphaAnimation anim = new AlphaAnimation(start, end);
    anim.setInterpolator(DECELERATE_CUBIC);
    anim.setDuration(ANIM_DUR);
    return anim;
}
 
Example 20
Source File: SplashActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
@Override
	protected void onCreate(Bundle arg0) {
	    final View view = View.inflate(this, R.layout.activity_splash, null);
		setContentView(view);
		super.onCreate(arg0);
		initFile() ;
		 
//		versionText = (TextView) findViewById(R.id.tv_version);

//		versionText.setText(getVersion());
		AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f);
		animation.setDuration(1500);
		view.startAnimation(animation);
		
		
		 

	}