Java Code Examples for android.view.View.startAnimation()

The following are Jave code examples for showing how to use startAnimation() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: FreeStreams-TVLauncher   File: WoDouGameBaseFragment.java   Source Code and License Vote up 7 votes
@Override
public void onFocusChange(View v, boolean hasFocus) {

    int focus = 0;
    if (hasFocus) {
        focus = R.anim.enlarge;
    } else {
        focus = R.anim.decrease;
    }
    //如果有焦点就放大,没有焦点就缩小
    Animation mAnimation = AnimationUtils.loadAnimation(
            getActivity().getApplication(), focus);
    mAnimation.setBackgroundColor(Color.TRANSPARENT);
    mAnimation.setFillAfter(hasFocus);
    v.startAnimation(mAnimation);
    mAnimation.start();
    v.bringToFront();
}
 
Example 2
Project: javaide   File: AndroidTreeView.java   Source Code and License Vote up 6 votes
private static void expand(final View v) {
    v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LinearLayout.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
Example 3
Project: Hillffair17   File: GalleryView.java   Source Code and License Vote up 6 votes
public  void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation()
    {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if(interpolatedTime == 1){
                v.setVisibility(View.GONE);
            }else{
                v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
Example 4
Project: buildAPKsSamples   File: ListViewItemAnimations.java   Source Code and License Vote up 6 votes
/**
 * Sets the horizontal position and translucency of the view being swiped.
 */
@SuppressLint("NewApi")
private void setSwipePosition(View view, float deltaX) {
    float fraction = Math.abs(deltaX) / view.getWidth();
    if (isRuntimePostGingerbread()) {
        view.setTranslationX(deltaX);
        view.setAlpha(1 - fraction);
    } else {
        // Hello, Gingerbread!
        TranslateAnimation swipeAnim = new TranslateAnimation(deltaX, deltaX, 0, 0);
        mCurrentX = deltaX;
        mCurrentAlpha = (1 - fraction);
        AlphaAnimation alphaAnim = new AlphaAnimation(mCurrentAlpha, mCurrentAlpha);
        AnimationSet set = new AnimationSet(true);
        set.addAnimation(swipeAnim);
        set.addAnimation(alphaAnim);
        set.setFillAfter(true);
        set.setFillEnabled(true);
        view.startAnimation(set);
    }
}
 
Example 5
Project: SciChart.Android.Examples   File: ViewAnimator.java   Source Code and License Vote up 6 votes
private void animateHideView(final int position) {
    final View view = viewList.get(position);

    FlipAnimation rotation = createFlipAnimation(0, -90, view.getWidth(), view.getHeight() / 2.0f);
    rotation.setAnimationListener(new FlipAnimationsListenerBase(view) {
        @Override
        public void onAnimationEnd(Animation animation) {
            super.onAnimationEnd(animation);

            view.setVisibility(View.INVISIBLE);
            if (position == viewList.size() - 1) {
                animatorListener.setViewsClickable(true);
                drawerLayout.closeDrawers();
            }
        }
    });

    view.startAnimation(rotation);
}
 
Example 6
Project: boohee_v5.6   File: a.java   Source Code and License Vote up 6 votes
private View a(Context context) {
    View linearLayout = new LinearLayout(context);
    LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, a(context, (float) IntFloatWheelView.DEFAULT_VALUE));
    layoutParams.gravity = 17;
    linearLayout.setOrientation(0);
    linearLayout.setLayoutParams(layoutParams);
    Drawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(-450944201);
    gradientDrawable.setCornerRadius((float) a(context, 5.0f));
    linearLayout.setBackgroundDrawable(gradientDrawable);
    View imageView = new ImageView(context);
    layoutParams = new LinearLayout.LayoutParams(a(context, 20.0f), a(context, 20.0f));
    layoutParams.gravity = 16;
    layoutParams.setMargins(a(this.a.f, 17.0f), a(this.a.f, 10.0f), a(this.a.f, 8.0f), a(this.a.f, 10.0f));
    imageView.setLayoutParams(layoutParams);
    imageView.setScaleType(ScaleType.FIT_CENTER);
    imageView.setImageDrawable(a(context, a.d));
    Animation rotateAnimation = new RotateAnimation(0.0f, 359.0f, 1, 0.5f, 1, 0.5f);
    rotateAnimation.setRepeatCount(-1);
    rotateAnimation.setDuration(900);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    imageView.startAnimation(rotateAnimation);
    View textView = new TextView(context);
    textView.setText(TextUtils.isEmpty(this.a.g) ? a.a : this.a.g);
    textView.setTextSize(16.0f);
    textView.setTextColor(-1);
    layoutParams = new LinearLayout.LayoutParams(-2, -2);
    layoutParams.gravity = 16;
    layoutParams.setMargins(0, 0, a(context, 17.0f), 0);
    textView.setLayoutParams(layoutParams);
    linearLayout.addView(imageView);
    linearLayout.addView(textView);
    return linearLayout;
}
 
Example 7
Project: Pocket-Plays-for-Twitch   File: AnimationService.java   Source Code and License Vote up 6 votes
/**
 * For the Activity Circle Icon and text
 */

public static AnimationSet startAlphaRevealAnimation(final View VIEW) {
	final int ANIMATION_DURATION = 1000;

	final Animation mShowViewAnimation = new AlphaAnimation(0f, 1f);
	mShowViewAnimation.setDuration(ANIMATION_DURATION);

	AnimationSet mAnimations = new AnimationSet(true);
	mAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
	mAnimations.addAnimation(mShowViewAnimation);
	mAnimations.setFillAfter(true);

       if(VIEW != null)
	    VIEW.startAnimation(mAnimations);

	return mAnimations;
}
 
Example 8
Project: Lunary-Ethereum-Wallet   File: CollapseAnimator.java   Source Code and License Vote up 6 votes
public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
Example 9
Project: MusicX-music-player   File: Helper.java   Source Code and License Vote up 5 votes
/**
 * Rotate ImageView
 *
 * @param view
 */
public static void rotationAnim(@NonNull View view) {
    RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation1.setInterpolator(new LinearInterpolator());
    rotateAnimation1.setDuration(300);
    rotateAnimation1.setRepeatCount(0);
    view.startAnimation(rotateAnimation1);
}
 
Example 10
Project: photo-editor-android   File: UtilFunctions.java   Source Code and License Vote up 5 votes
public static void enableView(View v) {
    if (Build.VERSION.SDK_INT >= 11) {
        try {
            v.setAlpha(1.0f);
            return;
        } catch (Exception e) {
        }
    } else {
        enableAnim.setDuration(100);
        enableAnim.setFillAfter(true);
        v.startAnimation(enableAnim);
    }
}
 
Example 11
Project: BuddyBook   File: BookGridAdapterFirebase.java   Source Code and License Vote up 5 votes
private void setAnimation(View viewToAnimate, int position) {
    // If the bound view wasn't previously displayed on screen, it's animated
    if (position > mLastPosition) {
        Animation animation = AnimationUtils.loadAnimation(mContext, android.R.anim.slide_in_left);
        viewToAnimate.startAnimation(animation);
        mLastPosition = position;
    }
}
 
Example 12
Project: boohee_v5.6   File: StateListAnimator.java   Source Code and License Vote up 5 votes
private void start(Tuple match) {
    this.mRunningAnimation = match.mAnimation;
    View view = getTarget();
    if (view != null) {
        view.startAnimation(this.mRunningAnimation);
    }
}
 
Example 13
Project: WordLing   File: WordpacksListActivity.java   Source Code and License Vote up 5 votes
public void openFABAnimation(final View view, final View hint) {
    Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);

    // Listener changes visibility to GONE on finish
    view.setVisibility(View.VISIBLE);
    hint.setVisibility(View.VISIBLE);

    hint.startAnimation(slideUp);
    view.startAnimation(slideUp);
}
 
Example 14
Project: PhotoPickApp   File: AnimationUtil.java   Source Code and License Vote up 5 votes
public static void showLine(Context context, View top, View bottom) {
    Animation topTranslateAnimation=new TranslateAnimation(0, 0, -DensityUtil.dip2px(context, 56f), 0);
    topTranslateAnimation.setDuration(300);
    topTranslateAnimation.setInterpolator(context, android.R.anim.linear_interpolator);
    topTranslateAnimation.setFillAfter(true);
    top.startAnimation(topTranslateAnimation);

    Animation bottomTranslateAnimation=new TranslateAnimation(0, 0, DensityUtil.dip2px(context, 56f), 0);
    bottomTranslateAnimation.setDuration(300);
    bottomTranslateAnimation.setInterpolator(context, android.R.anim.linear_interpolator);
    bottomTranslateAnimation.setFillAfter(true);
    bottom.startAnimation(bottomTranslateAnimation);
    top.setVisibility(View.VISIBLE);
    bottom.setVisibility(View.VISIBLE);
}
 
Example 15
Project: utils-android   File: AnimUtils.java   Source Code and License Vote up 5 votes
/**
 * развернуть элемент
 *
 * @param v - тот кого мы будем разворачивать
 */
public static void expand(final View v) {
    v.measure(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    // Older versions of android (pre API 21) cancel animations for views with a height of 0.
    v.getLayoutParams().height = 1;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ?
                    WindowManager.LayoutParams.WRAP_CONTENT :
                    (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext()
            .getResources()
            .getDisplayMetrics().density));
    v.startAnimation(a);
}
 
Example 16
Project: Mire   File: AnimUtils.java   Source Code and License Vote up 5 votes
public static void _alphaAnimationEnter(@NonNull Context context, @NonNull View view)
{
	Animation alpha = AnimationUtils.loadAnimation(context, R.anim.alpha_anim_visible);
	
	view.startAnimation(alpha);
	view.setVisibility(View.VISIBLE);
}
 
Example 17
Project: RecyclerWheelPicker   File: WheelPicker.java   Source Code and License Vote up 5 votes
public void doExitAnim(final View contentView, long animDuration) {
    if (builder.gravity == Gravity.BOTTOM) {
        ValueAnimator exitAnimator = ValueAnimator.ofFloat(0, contentView.getHeight());
        exitAnimator.setDuration(animDuration);
        exitAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                contentView.setTranslationY(value);
            }
        });
        exitAnimator.start();
    } else {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F,
                Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
        scaleAnimation.setDuration(animDuration);
        scaleAnimation.setFillAfter(true);
        contentView.startAnimation(scaleAnimation);
    }
}
 
Example 18
Project: EVideoRecorder   File: ERecorderActivityImpl.java   Source Code and License Vote up 5 votes
/**
 * 缩小动画
 *
 * @param v view
 */
static void scaleSmallAnim(View v) {
    ScaleAnimation an1 = new ScaleAnimation(1f, 0.8f, 1f, 0.8f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    an1.setDuration(200);
    an1.setFillAfter(true);
    v.startAnimation(an1);
}
 
Example 19
Project: letv   File: FadeInBitmapDisplayer.java   Source Code and License Vote up 5 votes
public static void animate(View imageView, int durationMillis) {
    if (imageView != null) {
        AlphaAnimation fadeImage = new AlphaAnimation(0.0f, 1.0f);
        fadeImage.setDuration((long) durationMillis);
        fadeImage.setInterpolator(new DecelerateInterpolator());
        imageView.startAnimation(fadeImage);
    }
}
 
Example 20
Project: Hotspot-master-devp   File: AnimationUtil.java   Source Code and License Vote up 4 votes
private static void baseIn(View view, Animation animation, long durationMillis, long delayMillis) {
	setEffect(animation, Default, durationMillis, delayMillis);
	view.setVisibility(View.VISIBLE);
	view.startAnimation(animation);
}