android.view.animation.Animation Java Examples

The following examples show how to use android.view.animation.Animation. 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: WelcomeFragment.java    From fresco with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  final SimpleDraweeView draweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
  draweeView.setActualImageResource(R.drawable.logo);
  draweeView.setOnClickListener(
      new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          final RotateAnimation rotateAnimation =
              new RotateAnimation(
                  0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
          rotateAnimation.setDuration(1000);
          rotateAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
          draweeView.startAnimation(rotateAnimation);
        }
      });

  final Button buttonGitHub = (Button) view.findViewById(R.id.button_github);
  setUriIntent(buttonGitHub, URL_GITHUB);

  final Button buttonDocumentation = (Button) view.findViewById(R.id.button_documentation);
  setUriIntent(buttonDocumentation, URL_DOCUMENTATION);
}
 
Example #2
Source File: AppRate.java    From discreet-app-rate with Apache License 2.0 6 votes vote down vote up
private void displayViews(ViewGroup mainView) {
    activity.addContentView(mainView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));


    if (mainView != null) {
        Animation fadeInAnimation;
        if (fromTop) {
            fadeInAnimation = AnimationUtils.loadAnimation(activity, R.anim.fade_in_from_top);
        } else {
            fadeInAnimation = AnimationUtils.loadAnimation(activity, R.anim.fade_in);
        }
        mainView.startAnimation(fadeInAnimation);
    }

    if (onShowListener != null) onShowListener.onRateAppShowing(this, mainView);
}
 
Example #3
Source File: CollapseView.java    From AndroidProjects with MIT License 6 votes vote down vote up
/**
 * 折叠
 *
 * @param view 视图
 */
private void collapse(final View view) {
    final int measuredHeight = view.getMeasuredHeight();
    Animation animation = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            Log.e("TAG", "interpolatedTime = " + interpolatedTime);
            if (interpolatedTime == 1) {
                mContentRelativeLayout.setVisibility(GONE);
            } else {
                view.getLayoutParams().height = measuredHeight - (int) (measuredHeight * interpolatedTime);
                view.requestLayout();
            }
        }
    };
    animation.setDuration(duration);
    view.startAnimation(animation);
}
 
Example #4
Source File: ExtendBaseView.java    From imsdk-android with MIT License 6 votes vote down vote up
public void startAnimate(int count)
{
    Animation fadeIn = new AlphaAnimation(0.2f, 1f);
    fadeIn.setInterpolator(new DecelerateInterpolator()); //add this
    fadeIn.setDuration(1000);

    Animation fadeOut = new AlphaAnimation(1f, 0.2f);
    fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
    fadeOut.setStartOffset(1000);
    fadeOut.setDuration(1000);

    final AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(fadeIn);
    animationSet.addAnimation(fadeOut);
    animationSet.setRepeatCount(count);
    animationSet.setRepeatMode(Animation.REVERSE);
    setAnimation(animationSet);
    animationSet.start();
}
 
Example #5
Source File: ViewHelper.java    From DMusic with Apache License 2.0 6 votes vote down vote up
/**
 * <p>对 View 做透明度变化的进场动画。</p>
 * <p>相关方法 {@link #fadeOut(View, int, Animation.AnimationListener, boolean)}</p>
 *
 * @param view            做动画的 View
 * @param duration        动画时长(毫秒)
 * @param listener        动画回调
 * @param isNeedAnimation 是否需要动画
 */
public static AlphaAnimation fadeIn(View view, int duration, Animation.AnimationListener listener, boolean isNeedAnimation) {
    if (view == null) {
        return null;
    }
    if (isNeedAnimation) {
        view.setVisibility(View.VISIBLE);
        AlphaAnimation alpha = new AlphaAnimation(0, 1);
        alpha.setInterpolator(new DecelerateInterpolator());
        alpha.setDuration(duration);
        alpha.setFillAfter(true);
        if (listener != null) {
            alpha.setAnimationListener(listener);
        }
        view.startAnimation(alpha);
        return alpha;
    } else {
        view.setAlpha(1);
        view.setVisibility(View.VISIBLE);
        return null;
    }
}
 
Example #6
Source File: SlothActivity.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {
    super.onSizeChanged(width, height, oldw, oldh);
    Random random = new Random();
    Interpolator interpolator = new LinearInterpolator();

    money_count = Math.max(width, height) / 30;
    coords = new int[money_count][];
    drawables.clear();
    for (int i = 0; i < money_count; i++) {
        Animation animation = new TranslateAnimation(0, height / 10
                - random.nextInt(height / 5), 0, height + 30);
        animation.setDuration(10 * height + random.nextInt(5 * height));
        animation.setRepeatCount(-1);
        animation.initialize(10, 10, 10, 10);
        animation.setInterpolator(interpolator);

        coords[i] = new int[] { random.nextInt(width - 30), -80 };

        drawables.add(new AnimateDrawable(money_sign, animation));
        animation.setStartOffset(random.nextInt(20 * height));
        animation.startNow();
    }
}
 
Example #7
Source File: MainNavigationActivity.java    From beaconloc with Apache License 2.0 6 votes vote down vote up
public void hideFab() {
    fab.clearAnimation();
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.hide_fab);
    fab.startAnimation(animation);

    CoordinatorLayout.LayoutParams params =
            (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
    FloatingActionButton.Behavior behavior =
            (FloatingActionButton.Behavior) params.getBehavior();

    if (behavior != null) {
        behavior.setAutoHideEnabled(false);
    }

    fab.hide();
}
 
Example #8
Source File: UiUtils.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Collapse a view which has already expanded
 *
 * @param v
 */
public static void collapseViews(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) * 1);
    v.startAnimation(a);
}
 
Example #9
Source File: FlipLoadingLayout.java    From Social with Apache License 2.0 6 votes vote down vote up
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
Example #10
Source File: FlipLoadingLayout.java    From sctalk with Apache License 2.0 6 votes vote down vote up
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
Example #11
Source File: XHeaderView.java    From PullToRefresh with Apache License 2.0 6 votes vote down vote up
private void initView(Context context) {
    // Initial set header view height 0
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
    mContainer = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.vw_header, null);
    addView(mContainer, lp);
    setGravity(Gravity.BOTTOM);

    mArrowImageView = (ImageView) findViewById(R.id.header_arrow);
    mHintTextView = (TextView) findViewById(R.id.header_hint_text);
    mProgressBar = (ProgressBar) findViewById(R.id.header_progressbar);

    mRotateUpAnim = new RotateAnimation(0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateUpAnim.setFillAfter(true);

    mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateDownAnim.setFillAfter(true);
}
 
Example #12
Source File: ReactNativeFragment.java    From native-navigation with MIT License 6 votes vote down vote up
@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
  if (!enter) {
    // React Native will flush the UI cache as soon as we unmount it. This will cause the view to
    // disappear unless we delay it until after the fragment animation.
    if (transit == FragmentTransaction.TRANSIT_NONE && nextAnim == 0) {
      reactRootView.unmountReactApplication();
    } else {
      contentContainer.unmountReactApplicationAfterAnimation(reactRootView);

    }
    reactRootView = null;
  }
  if (getActivity() instanceof ScreenCoordinatorComponent) {
    ScreenCoordinator screenCoordinator =
            ((ScreenCoordinatorComponent) getActivity()).getScreenCoordinator();
    if (screenCoordinator != null) {
      // In some cases such as TabConfig, the screen may be loaded before there is a screen
      // coordinator but it doesn't live inside of any back stack and isn't visible.
      return screenCoordinator.onCreateAnimation(transit, enter, nextAnim);
    }
  }
  return null;
}
 
Example #13
Source File: CaptureActivity.java    From ScanZbar with Apache License 2.0 6 votes vote down vote up
private void initView() {
    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);
    findViewById(R.id.capture_imageview_back).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    isHasSurface = false;
    beepManager = new BeepManager(this);

    TranslateAnimation 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,
            0.9f);
    animation.setDuration(3000);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);

}
 
Example #14
Source File: ExProgressView.java    From support with Apache License 2.0 6 votes vote down vote up
public ExProgressView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(Color.GREEN);
    mRect = new Rect();
    mRectWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20,
            getContext().getResources().getDisplayMetrics());
    mRectHeight = 4 * mRectWidth;
    mGap = (int) (mRectWidth * 0.8f);
    ObjectAnimator animator = ObjectAnimator.ofInt(this, mIndex, 0, 1, 2, 3, 4, 5);
    animator.setInterpolator(new LinearInterpolator());
    animator.setDuration(750);
    animator.setRepeatMode(Animation.RESTART);
    animator.setRepeatCount(Animation.INFINITE);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            invalidate();
        }
    });
    animator.start();
}
 
Example #15
Source File: AccountActivity.java    From smartcoins-wallet with MIT License 6 votes vote down vote up
private void updateBlockNumberHead() {
    final Handler handler = new Handler();

    final Activity myActivity = this;

    final Runnable updateTask = new Runnable() {
        @Override
        public void run() {
            if (Application.isConnected()) {
                ivSocketConnected.setImageResource(R.drawable.icon_connecting);
                tvBlockNumberHead.setText(Application.blockHead);
                ivSocketConnected.clearAnimation();
            } else {
                ivSocketConnected.setImageResource(R.drawable.icon_disconnecting);
                Animation myFadeInAnimation = AnimationUtils.loadAnimation(myActivity.getApplicationContext(), R.anim.flash);
                ivSocketConnected.startAnimation(myFadeInAnimation);
            }
            handler.postDelayed(this, 1000);
        }
    };
    handler.postDelayed(updateTask, 1000);
}
 
Example #16
Source File: ScrollAwareFABBehavior.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Same animation that FloatingActionButton.Behavior
 * uses to show the FAB when the AppBarLayout enters
 *
 * @param floatingActionButton FAB
 */
//
private void animateIn(FloatingActionButton floatingActionButton) {
    if (SmartphonePreferencesHandler.getUseOptionsMenuInsteadOfFAB()) {
        return;
    }
    floatingActionButton.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(floatingActionButton).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(floatingActionButton.getContext(), android.R.anim.fade_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        floatingActionButton.startAnimation(anim);
    }
}
 
Example #17
Source File: CommonViewAnimationActivity.java    From Android-Animation-Set with Apache License 2.0 6 votes vote down vote up
private Animation getAnimationSet(boolean fromXML) {
    if (fromXML) {
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.view_animation);
        return animation;
    } else {
        AnimationSet innerAnimationSet = new AnimationSet(true);
        innerAnimationSet.setInterpolator(new BounceInterpolator());
        innerAnimationSet.setStartOffset(1000);
        innerAnimationSet.addAnimation(getScaleAnimation());
        innerAnimationSet.addAnimation(getTranslateAnimation());

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setInterpolator(new LinearInterpolator());

        animationSet.addAnimation(getAlphaAnimation());
        animationSet.addAnimation(getRotateAnimation());
        animationSet.addAnimation(innerAnimationSet);

        return animationSet;
    }
}
 
Example #18
Source File: BannerAdView.java    From mobile-sdk-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onAnimationEnd(Animation animation) {
    animation.setAnimationListener(null);
    final Displayable oldView = this.oldView.get();
    final Animator animator = this.animator.get();

    if (oldView != null && animator != null) {
        // Make sure to post actions on UI thread
        oldView.getView().getHandler().post(new Runnable() {
            public void run() {
                animator.clearAnimation();
                oldView.destroy();
                animator.setAnimation();
            }
        });
    }
}
 
Example #19
Source File: ClearEditText.java    From AndroidUI with MIT License 5 votes vote down vote up
/**
 * 晃动动画
 * @param counts 0.5秒钟晃动多少下
 * @return
 */
private Animation shakeAnimation(int counts){
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
 
Example #20
Source File: MultiPaneActivity.java    From MongoExplorer with MIT License 5 votes vote down vote up
private void animateFromOffscreenToLeftPane(View view) {
   	((MarginLayoutParams)view.getLayoutParams()).width = mLeftPaneWidth;
   	view.requestLayout();

	Animation animation = new LeftMarginAnimation(view, -mLeftPaneWidth, 0);
	view.startAnimation(animation);
}
 
Example #21
Source File: FloatView.java    From RePlugin-GameSdk with Apache License 2.0 5 votes vote down vote up
public void show()
{
  if (getVisibility() != View.VISIBLE)
  {
    setVisibility(View.VISIBLE);
    if (mShowLoader)
    {
      mIvFloatLogo.setImageResource(RUtils.drawable(RePlugin.getPluginContext(), "fun_default_icon"));
      
      mWmParams.alpha = 1.0F;
      mWindowManager.updateViewLayout(this, mWmParams);
      
      timerForHide();
      
      mShowLoader = false;
      Animation rotaAnimation = AnimationUtils.loadAnimation(RePlugin.getPluginContext(), RUtils.anim(RePlugin.getPluginContext(), "raink_loading_anim"));
      
      rotaAnimation.setInterpolator(new LinearInterpolator());
      mIvFloatLoader.startAnimation(rotaAnimation);
      mTimer.schedule(new TimerTask()
      {
        public void run()
        {
          mTimerHandler.sendEmptyMessage(HANDLER_TYPE_CANCEL_ANIM);
        }
      }, 3000L);
    }
  }
}
 
Example #22
Source File: RepeatListener.java    From Kore with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for a repeat listener, with animation and vibration
 *
 * @param initialInterval The interval after first click event. If negative, no repeat will occur
 * @param repeatInterval The interval after second and subsequent click events. If negative, no repeat will occur
 * @param clickListener The OnClickListener, that will be called periodically
 * @param animDown Animation to play on touch
 * @param animUp Animation to play on release
 * @param context Context used to access preferences and services
 */
public RepeatListener(int initialInterval, int repeatInterval, View.OnClickListener clickListener,
                      Animation animDown, Animation animUp, Context context) {
    this.initialInterval = initialInterval;
    this.repeatInterval = repeatInterval;
    this.clickListener = clickListener;

    this.animDown = animDown;
    this.animUp = animUp;

    this.context = context;
}
 
Example #23
Source File: KJAnimations.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 缩放 Scale
 */
public static Animation getScaleAnimation(float scaleXY, long durationMillis) {
    ScaleAnimation scale = new ScaleAnimation(1.0f, scaleXY, 1.0f, scaleXY,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    scale.setDuration(durationMillis);
    return scale;
}
 
Example #24
Source File: EmptyLayout.java    From AndroidEmptyLayout with Apache License 2.0 5 votes vote down vote up
private static Animation getRotateAnimation() {
    final RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    rotateAnimation.setDuration(1500);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    return rotateAnimation;
}
 
Example #25
Source File: MaterialProgressDrawable.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRunning() {
    final ArrayList<Animation> animators = mAnimators;
    final int N = animators.size();
    for (int i = 0; i < N; i++) {
        final Animation animator = animators.get(i);
        if (animator.hasStarted() && !animator.hasEnded()) {
            return true;
        }
    }
    return false;
}
 
Example #26
Source File: MainActivity.java    From Modularity with Apache License 2.0 5 votes vote down vote up
/**
 * 显示Toolbar的退出tip
 */
public void showExitTip() {
    TextView view = (TextView) findViewById(R.id.titlebar_text_exittip);
    view.setVisibility(View.VISIBLE);
    Animation a = AnimationUtil.getTranslateAnimation(0f, 0f, -getToolbar().getHeight(), 0f, 300);
    view.startAnimation(a);
}
 
Example #27
Source File: CompassActivity.java    From MuslimMateAndroid with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Function to init compass activity
 */
private void init() {
    countryName = (TextView) findViewById(R.id.textView11);
    if (MainActivity.locationInfo != null)
        countryName.setText(getResources().getConfiguration()
                .locale.getDisplayLanguage().equals("العربية")
                ? ConfigPreferences.getLocationConfig(this).name_english
                : ConfigPreferences.getLocationConfig(this).name);

    //init compass activity views
    Quibladegree = (TextView) findViewById(R.id.textView12);
    Quibladegree.setText(getString(R.string.qibla_direction) + " " + ConfigPreferences.getQuibla(this));
    indicator = (ImageView) findViewById(R.id.imageView2);
    compass = (RelativeLayout) findViewById(R.id.compassContainer);
    compassMapContainer = (RelativeLayout) findViewById(R.id.compassMapContainer);
    compassMain = (RelativeLayout) findViewById(R.id.compassMain);
    smallCircleLevel = (ImageView) findViewById(R.id.smallCircle);
    innerPosition = (RelativeLayout) findViewById(R.id.innerplace);
    pointerIndicatorInner = (ImageView) findViewById(R.id.poinerInner);
    redCircle = (ImageView) findViewById(R.id.red_circle);
    errorImage = (ImageView) findViewById(R.id.error);

    //init sensor services
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    compassLevel = (ImageView) findViewById(R.id.compassLevel);

    //animate compass pointer
    RotateAnimation ra = new RotateAnimation(currentDegree, MainActivity.quiblaDegree,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    ra.setDuration(400);
    ra.setFillAfter(true);
    indicator.startAnimation(ra);
    pointerIndicatorInner.startAnimation(ra);
}
 
Example #28
Source File: TextBannerView.java    From TextBannerView with Apache License 2.0 5 votes vote down vote up
/**
 * 设置进入动画和离开动画
 *
 * @param inAnimResId  进入动画的resID
 * @param outAnimResID 离开动画的resID
 */
private void setInAndOutAnimation(@AnimRes int inAnimResId, @AnimRes int outAnimResID) {
    Animation inAnim = AnimationUtils.loadAnimation(getContext(), inAnimResId);
    inAnim.setDuration(animDuration);
    mViewFlipper.setInAnimation(inAnim);

    Animation outAnim = AnimationUtils.loadAnimation(getContext(), outAnimResID);
    outAnim.setDuration(animDuration);
    mViewFlipper.setOutAnimation(outAnim);
}
 
Example #29
Source File: MyRecyclerView.java    From IdeaTrackerPlus with MIT License 5 votes vote down vote up
/**
 * Animate the view to shrink vertically
 *
 * @param v
 * @param al
 */
private void collapse(final View v, Animation.AnimationListener al) {

    final int initialHeight = v.getMeasuredHeight();

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

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

    if (al != null) {
        anim.setAnimationListener(al);
    }
    anim.setDuration(ANIMATION_DURATION);
    v.startAnimation(anim);
}
 
Example #30
Source File: ArcMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}