List of usage examples for android.view.animation Animation setInterpolator
public void setInterpolator(Interpolator i)
From source file:de.madvertise.android.sdk.MadvertiseView.java
private Animation createAnimation(final boolean isOutAnimation) { Animation animation = null; if (isOutAnimation) { if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_FADE)) { animation = new AlphaAnimation(1.0f, 0.0f); animation.setDuration(700);//ww w . j a v a 2 s . c o m } else if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_LEFT_TO_RIGHT)) { animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); animation.setDuration(900); animation.setInterpolator(new AccelerateInterpolator()); } else if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_TOP_DOWN)) { animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f); animation.setDuration(900); animation.setInterpolator(new AccelerateInterpolator()); } } else { if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_FADE)) { animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(1200); } else if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_LEFT_TO_RIGHT)) { animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); animation.setDuration(900); animation.setInterpolator(new AccelerateInterpolator()); } else if (mAnimationType != null && mAnimationType.equals(MadvertiseUtil.ANIMATION_TYPE_TOP_DOWN)) { animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); animation.setDuration(900); animation.setInterpolator(new AccelerateInterpolator()); } } // create a no-animation animation // if (animation == null) { // animation = new AlphaAnimation(1.0f, 1.0f); // } return animation; }
From source file:glas.bbsystem.views.widgets.TabLayout.java
private void animateToTab(int newPosition) { clearAnimation();// w ww. j av a2 s . c om if (newPosition == Tab.INVALID_POSITION) { return; } if (getWindowToken() == null || !ViewCompat.isLaidOut(this)) { // If we don't have a window token, or we haven't been laid out yet // just draw the new // position now setScrollPosition(newPosition, 0f); return; } final int startScrollX = getScrollX(); final int targetScrollX = calculateScrollXForTab(newPosition, 0); final int duration = ANIMATION_DURATION; if (startScrollX != targetScrollX) { final Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float value = lerp(startScrollX, targetScrollX, interpolatedTime); scrollTo((int) value, 0); } }; animation.setInterpolator(INTERPOLATOR); animation.setDuration(duration); startAnimation(animation); } // Now animate the indicator mTabStrip.animateIndicatorToPosition(newPosition, duration); }
From source file:com.jecelyin.android.common.widget.TabLayout.java
private void animateToTab(int newPosition) { clearAnimation();//from w w w .jav a 2 s .com if (newPosition == Tab.INVALID_POSITION) { return; } if (getWindowToken() == null || !ViewCompat.isLaidOut(this)) { // If we don't have a window token, or we haven't been laid out yet just draw the new // position now setScrollPosition(newPosition, 0f, true); return; } final int startScrollX = getScrollX(); final int targetScrollX = calculateScrollXForTab(newPosition, 0); final int duration = ANIMATION_DURATION; if (startScrollX != targetScrollX) { final Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float value = lerp(startScrollX, targetScrollX, interpolatedTime); scrollTo((int) value, 0); } }; animation.setInterpolator(INTERPOLATOR); animation.setDuration(duration); startAnimation(animation); } // Now animate the indicator mTabStrip.animateIndicatorToPosition(newPosition, duration); }
From source file:cw.kop.autobackground.sources.SourceInfoFragment.java
@Override public void onStart() { super.onStart(); Animation animation; if (sourcePosition == -1) { animation = new Animation() { @Override/*from w w w. j a v a 2s . co m*/ protected void applyTransformation(float interpolatedTime, Transformation t) { sourceSpinnerText.setAlpha(interpolatedTime); sourceSpinner.setAlpha(interpolatedTime); sourceTitle.setAlpha(interpolatedTime); settingsContainer.setAlpha(interpolatedTime); sourceUse.setAlpha(interpolatedTime); } }; } else { animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { settingsContainer.setAlpha(interpolatedTime); sourceUse.setAlpha(interpolatedTime); } }; } animation.setDuration(FADE_IN_TIME); animation.setInterpolator(new DecelerateInterpolator(3.0f)); settingsContainer.startAnimation(animation); }
From source file:org.readium.sdk.android.biblemesh.WebViewActivity.java
private void snapBack() { if (mWebview.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { final ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) mWebview .getLayoutParams();// w ww .j a v a 2s . c o m final int startValueX = marginLayoutParams.leftMargin; final int endValueX = 0; //final float startValueAlpha = mWebview.getAlpha(); mWebview.clearAnimation(); Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { int leftMarginInterpolatedValue = (int) (startValueX + (endValueX - startValueX) * interpolatedTime); //float alphaInterpolatedValue = startValueAlpha -startValueAlpha * interpolatedTime; marginLayoutParams.leftMargin = leftMarginInterpolatedValue; marginLayoutParams.rightMargin = -leftMarginInterpolatedValue; //mWebview.setAlpha(alphaInterpolatedValue); mWebview.requestLayout(); } }; animation.setDuration(200); animation.setInterpolator(new DecelerateInterpolator()); mWebview.startAnimation(animation); } }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
private void initRotateNotification(int orientation) { if (rotatorLayout != null && showLandscapeNotification) { if (!isRecording && (orientation == 90 || orientation == 270)) { try { int height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.gui_element_2size); Animation rotation = new RotateAnimation(0, -180, height / 2, height / 2); rotation.setDuration(2000); rotation.setRepeatCount(1000); rotation.setInterpolator(new DecelerateInterpolator()); rotatorLayout.findViewById(R.id.rotatorImageView).startAnimation(rotation); rotatorLayout.findViewById(R.id.rotatorImageView).setVisibility(View.VISIBLE); rotatorLayout.findViewById(R.id.rotatorInnerImageView).setVisibility(View.VISIBLE); } catch (Exception e) { e.printStackTrace();/*w ww. j a va2 s .co m*/ } } else { rotatorLayout.findViewById(R.id.rotatorInnerImageView).setVisibility(View.GONE); rotatorLayout.findViewById(R.id.rotatorImageView).setVisibility(View.GONE); rotatorLayout.findViewById(R.id.rotatorImageView).clearAnimation(); } } else //if we started video but orientation change already fired. Save and set orientation on rotator layout creation videoOrientation = orientation; }
From source file:de.mrapp.android.sidebar.Sidebar.java
/** * Animates the sidebar to be moved by a specific distance. * * @param show// w w w. jav a2 s. c o m * True, if the sidebar should be shown at the end of the animation, false otherwise * @param distance * The distance, the sidebar has to be moved by, as a {@link Float} value. If the * distance is negative, the sidebar will be moved to the left, if the distance is * positive, it will be moved to the right * @param animationSpeed * The speed of the animation in pixels per millisecond as a {@link Float} value * @param animationListener * The listener, which should be notified about the animation's progress, as an instance * of the type {@link AnimationListener}. The listener may not be null * @param interpolator * The interpolator, which should be used by the animation, as an instance of the type * {@link Interpolator}. The interpolator may not be null */ private void animateSidebar(final boolean show, final float distance, final float animationSpeed, @NonNull final AnimationListener animationListener, @NonNull final Interpolator interpolator) { if (!isDragging() && !isAnimationRunning()) { long duration = calculateAnimationDuration(distance, animationSpeed); Animation contentViewAnimation; if (getContentMode() == ContentMode.SCROLL) { contentViewAnimation = new ContentViewScrollAnimation(contentView, duration, distance, scrollRatio, 1 - getContentOverlayTransparency(), show); } else { contentViewAnimation = new ContentViewResizeAnimation(contentView, duration, distance, getLocation(), 1 - getContentOverlayTransparency(), show); } Animation sidebarViewAnimation = new SidebarViewAnimation(distance, duration, animationListener); contentViewAnimation.setInterpolator(interpolator); sidebarViewAnimation.setInterpolator(interpolator); contentView.startAnimation(contentViewAnimation); sidebarView.startAnimation(sidebarViewAnimation); } }
From source file:org.anurag.file.quest.TaskerActivity.java
/** * Creates the animation set for next ViewFlippers when loaded. * @return a customized animation for mViewFlippers *///from w w w .j a v a 2 s . c om private static Animation nextAnim() { Animation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(100); anim.setInterpolator(new AccelerateInterpolator()); return anim; }
From source file:org.anurag.file.quest.TaskerActivity.java
/** * Creates the animation set for previous ViewFlippers when loaded. * @return a customized animation for mViewFlippers *///w ww .j a v a 2 s. c o m private static Animation prevAnim() { Animation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(100); anim.setInterpolator(new AccelerateInterpolator()); return anim; }