setFillAfter()源码实例Demo

android.view.animation.ScaleAnimation#setFillAfter()源码实例Demo

下面列出了android.view.animation.ScaleAnimation#setFillAfter() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bither-android   文件: RawDataBinaryView.java
public void deleteLast(){
    int size = data.size();
    if(size <= 0){
        return;
    }
    data.remove(size - 1);
    final ImageView iv = (ImageView) ((FrameLayout) getChildAt(size - 1)).getChildAt(0);
    if(iv.getVisibility() == View.VISIBLE){
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(300);
        anim.setFillAfter(true);
        iv.startAnimation(anim);
        iv.postDelayed(new Runnable() {
            @Override
            public void run() {
                iv.setVisibility(View.INVISIBLE);
            }
        }, 300);
    }
}
 
源代码2 项目: glass_snippets   文件: HeadImageView.java
public void setScaleFactor(float factor) {
  if (getAnimation() != null && !getAnimation().hasEnded())
    getAnimation().cancel();
  
  if (factor < 1)
    factor=1;
  
  deactivate();
  
  ScaleAnimation a = new ScaleAnimation(mScaleFactor, factor, mScaleFactor, factor,
      Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);

  a.setDuration(500);
  a.setFillAfter(true);
  a.setFillEnabled(true);
  setAnimation(a);

  mScaleFactor = factor;
  MAX_SCROLL_X = MAX_SCROLL_Y = null;
  
  activate();
}
 
源代码3 项目: MusicPlayer   文件: Animation.java
private void startAnimation(List<Interpolator> interpolatorList) {
    for (int i = 0; i < interpolatorList.size(); i++) {
        Interpolator interpolator = interpolatorList.get(i);
        View view = root.getChildAt(i);
        //   TranslateAnimation Tanimation = new TranslateAnimation(0, displaySize.x - maxTextWidth - 2 * margin, 0, 0);
        ScaleAnimation animation = new ScaleAnimation(2, 1, 2, 1);
        //    RotateAnimation animation = new RotateAnimation(0,60);
        animation.setFillAfter(true);
        //     Tanimation.setFillAfter(true);
        animation.setDuration(ANIMATION_DURATION);
        //   Tanimation.setDuration(ANIMATION_DURATION);
        if (interpolator != null) {
            animation.setInterpolator(interpolator);
            //    Tanimation.setInterpolator(pp_interpolator);
        }

        //    view.startAnimation(Tanimation);
        view.startAnimation(animation);
        //   view.setRotation(60);
    }
}
 
源代码4 项目: android-open-project-demo   文件: Utils.java
public static Animation createScaleAnimation(View view, int parentWidth, int parentHeight,
        int toX, int toY) {
    // Difference in X and Y
    final int diffX = toX - view.getLeft();
    final int diffY = toY - view.getTop();

    // Calculate actual distance using pythagors
    float diffDistance = FloatMath.sqrt((toX * toX) + (toY * toY));
    float parentDistance = FloatMath
            .sqrt((parentWidth * parentWidth) + (parentHeight * parentHeight));

    ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.ABSOLUTE,
            diffX,
            Animation.ABSOLUTE, diffY);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(Math.round(diffDistance / parentDistance
            * Constants.SCALE_ANIMATION_DURATION_FULL_DISTANCE));

    return scaleAnimation;
}
 
源代码5 项目: star-zone-android   文件: AnimUtils.java
public static ScaleAnimation getScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue);
    scaleAnimation.setDuration(300L);
    scaleAnimation.setFillEnabled(true);
    scaleAnimation.setFillAfter(true);
    return scaleAnimation;
}
 
/**缩放
 * @param view
 * @param from 缩放开始比例0-1.0
 * @param to 缩放结束比例0-1.0
 * @param w
 * @param h
 */
public static void setViewScale(View view, float from, float to, int w, int h) {
    if (isAnimation) {
        ScaleAnimation animation = new ScaleAnimation(from, to, from, to,
                w/2, h/2);
        animation.setDuration(200);
        animation.setFillAfter(true);
        view.clearAnimation();
        view.setAnimation(animation);
        animation = null;
        System.gc();
    }
}
 
private Animation getScaleAnimation() {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 2f,
            1f, 2f,
            getWidth() / 2, getHeight() / 2);
    scaleAnimation.setDuration(2000);
    scaleAnimation.setRepeatCount(2);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setFillBefore(false);
    scaleAnimation.setRepeatMode(Animation.REVERSE);
    return scaleAnimation;
}
 
源代码8 项目: SimpleProject   文件: ViewAnimationUtil.java
public static void scale(View view, int fromX, int toX, int fromY, int toY, int duration, Interpolator interpolator) {
	ScaleAnimation animation = new ScaleAnimation(fromX, toX, fromY, toY);
	animation.setDuration(duration);
	animation.setFillAfter(true);
	animation.setInterpolator(interpolator);
	view.startAnimation(animation);
}
 
源代码9 项目: Gallery   文件: VersionDiffUtils.java
public static void scaleX(View view, float f) {
    if (view == null)
        return;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        view.setScaleX(f);
    } else {
        ScaleAnimation animation =new ScaleAnimation(f, f, f, f, 
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
        animation.setDuration(0);
        animation.setFillAfter(true);
        view.startAnimation(animation);
    }
}
 
源代码10 项目: PocketMaps   文件: MapActions.java
/**
 * start button: control button handler FAB
 */

private void initControlBtnHandler() {
    final ScaleAnimation anim = new ScaleAnimation(0, 1, 0, 1);
    anim.setFillBefore(true);
    anim.setFillAfter(true);
    anim.setFillEnabled(true);
    anim.setDuration(300);
    anim.setInterpolator(new OvershootInterpolator());

    controlBtn.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
            if (isMenuVisible()) {
                setMenuVisible(false);
                sideBarMenuVP.setVisibility(View.INVISIBLE);
                favourBtn.setVisibility(View.INVISIBLE);
                settingsBtn.setVisibility(View.INVISIBLE);
                controlBtn.setImageResource(R.drawable.ic_keyboard_arrow_up_white_24dp);
                controlBtn.startAnimation(anim);
            } else {
                setMenuVisible(true);
                sideBarMenuVP.setVisibility(View.VISIBLE);
                favourBtn.setVisibility(View.VISIBLE);
                settingsBtn.setVisibility(View.VISIBLE);
                controlBtn.setImageResource(R.drawable.ic_keyboard_arrow_down_white_24dp);
                controlBtn.startAnimation(anim);
            }
        }
    });
}
 
源代码11 项目: JayPS-AndroidApp   文件: AltitudeFragment.java
private void animateAltitudeBars(ImageView[] views, float[] displayValues) {

        for(int v =0; v < views.length;v++) {
            views[v].setMaxHeight(_view.getHeight());
            ScaleAnimation scale = new ScaleAnimation(1, 1, _prevValues[v], displayValues[v], Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 1.0f);
            scale.setFillAfter(true);
            scale.setDuration(500);
            scale.setInterpolator(new AccelerateInterpolator(1.0f));
            views[v].startAnimation(scale);
        }

        _prevValues = displayValues;

    }
 
源代码12 项目: Fatigue-Detection   文件: EffectsButton.java
ScaleAnimation createDownAnim() {
    ScaleAnimation localScaleAnimation = new ScaleAnimation(1.0F, 1.2F, 1.0F, 1.2F, 1, 0.5F, 1, 0.5F);
    localScaleAnimation.setDuration(50L);
    localScaleAnimation.setFillEnabled(true);
    localScaleAnimation.setFillBefore(false);
    localScaleAnimation.setFillAfter(true);
    return localScaleAnimation;
}
 
源代码13 项目: direct-select-android   文件: DSListView.java
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);
    }
}
 
源代码14 项目: actor-platform   文件: ViewUtils.java
public static void demoteView(final View view, boolean isAnimated) {
    if (view == null) {
        return;
    }

    if (isAnimated) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.1f, 1.0f, 1.1f, 1.0f, Animation.RELATIVE_TO_SELF, (float) 0.5, Animation.RELATIVE_TO_SELF, (float) 0.5);
        scaleAnimation.setDuration(isAnimated ? 150 : 0);
        scaleAnimation.setInterpolator(MaterialInterpolator.getInstance());
        scaleAnimation.setFillAfter(true);
        view.clearAnimation();
        view.startAnimation(scaleAnimation);
    }
}
 
源代码15 项目: lock-screen   文件: PinLockAdapter.java
private Animation scale(){
    ScaleAnimation scaleAnimation = new ScaleAnimation(.75F, 1f, .75F, 1f,
            Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);
    scaleAnimation.setDuration(BUTTON_ANIMATION_DURATION);
    scaleAnimation.setFillAfter(true);
    return  scaleAnimation;
}
 
源代码16 项目: ClockView   文件: WaveActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wave);
    scaleAnimation = new ScaleAnimation(1.2f, 1f, 1.2f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(500);
    scaleAnimation.setFillAfter(true);
    wave = (WaveView) findViewById(R.id.wave);
    head = (ImageView) findViewById(R.id.head);
    mPlayer = MediaPlayer.create(this, R.raw.water_wave);
    head.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            wave.addWave();
            head.startAnimation(scaleAnimation);
            if(mPlayer.isPlaying()){
                mPlayer.stop();
                try {
                    mPlayer.prepare();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            mPlayer.start();
        }
    });
    wave.start();
}
 
源代码17 项目: droidconat-2016   文件: Animations.java
public static void scale(View view, float ratioFrom, float ratioTo, long durationMillis) {
    ScaleAnimation anim = new ScaleAnimation(ratioFrom, ratioTo, ratioFrom, ratioTo, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setFillBefore(true);
    anim.setFillAfter(true);
    anim.setFillEnabled(true);
    anim.setDuration(durationMillis);
    anim.setInterpolator(new OvershootInterpolator());
    view.startAnimation(anim);
}
 
源代码18 项目: TvWidget   文件: AnimateFactory.java
/**
 * 缩放动画,用于缩放控件
 *
 * @param startScale 控件的起始尺寸倍率
 * @param endScale   控件的终点尺寸倍率
 * @return
 */
public static Animation zoomAnimation(float startScale, float endScale, long duration) {
    ScaleAnimation anim = new ScaleAnimation(startScale, endScale, startScale, endScale,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setFillAfter(true);
    anim.setDuration(duration);
    return anim;
}
 
源代码19 项目: Study_Android_Demo   文件: MainActivity.java
public void scaleAnim_java(View view) {
	// 2.����һ��ScaleAnimation����
	ScaleAnimation animation = new ScaleAnimation(1f, 3f, 1f, 3f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
	// ����ʱ��
	animation.setDuration(1000);
	// ����ֹͣ�����һ֡
	animation.setFillAfter(true);
	// 3.���Ŷ���
	iv_rocket.startAnimation(animation);

}
 
源代码20 项目: CatchPiggy   文件: AnimationButton.java
private Animation getActionDownAnimation() {
    ScaleAnimation animation = new ScaleAnimation(1, .9F, 1, .9F, Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);
    animation.setDuration(150);
    animation.setFillAfter(true);
    return animation;
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。