android.view.animation.TranslateAnimation#setDuration()源码实例Demo

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

源代码1 项目: ZXingProject   文件: CaptureActivity.java
@Override
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);

	Window window = getWindow();
	window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	setContentView(R.layout.activity_capture);

	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);

	inactivityTimer = new InactivityTimer(this);
	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(4500);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.RESTART);
	scanLine.startAnimation(animation);
}
 
源代码2 项目: CameraV   文件: UIHelpers.java
@SuppressLint("NewApi")
public static void translateY(final View view, float fromY, float toY, long duration)
{
	if (Build.VERSION.SDK_INT >= 12)
	{
		if (duration == 0)
			view.setTranslationY(toY);
		else
			view.animate().translationY(toY).setDuration(duration).start();
	}
	else
	{
		TranslateAnimation translate = new TranslateAnimation(0, 0, fromY, toY);
		translate.setDuration(duration);
		translate.setFillEnabled(true);
		translate.setFillBefore(true);
		translate.setFillAfter(true);
		addAnimation(view, translate);
	}
}
 
源代码3 项目: iSCAU-Android   文件: ClassTabWidget.java
/**
 * true the underline control to the click position
 * @param position
 */
public void changeWeekDay(int position){

    float offset = (float) (getWidth() - getPaddingLeft() - getPaddingRight()) / 7;

    LinearLayout.LayoutParams params = (LayoutParams) iv_underline.getLayoutParams();
    params.width = (int) offset;
    iv_underline.setLayoutParams(params);

    TranslateAnimation animation = new TranslateAnimation(
            offset * currentPosition ,position * offset,0,0);

    animation.setFillAfter(true);
    animation.setFillEnabled(true);
    animation.setDuration(300);
    iv_underline.startAnimation(animation);

    setTabTextStyle(currentPosition,false);
    setTabTextStyle(position,true);
    currentPosition = position;
}
 
/**
 * Translates the adapter in Y
 *
 * @param of offset in px
 */
public void translateHeader(float of) {
    float ofCalculated = of * mScrollMultiplier;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && of < mHeader.getHeight()) {
        mHeader.setTranslationY(ofCalculated);
    } else if (of < mHeader.getHeight()) {
        TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated);
        anim.setFillAfter(true);
        anim.setDuration(0);
        mHeader.startAnimation(anim);
    }
    mHeader.setClipY(Math.round(ofCalculated));
    if (mParallaxScroll != null) {
        final RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(0);
        float left;
        if (holder != null) {
            left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * mScrollMultiplier)));
        }else {
            left = 1;
        }
        mParallaxScroll.onParallaxScroll(left, of, mHeader);
    }
}
 
源代码5 项目: PLDroidShortVideo   文件: ViewOperator.java
private void startAppearAnimOnTop(final View view) {
    final TranslateAnimation showAnim = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1f,
            Animation.RELATIVE_TO_SELF, 0.0f);
    showAnim.setDuration(250);
    view.startAnimation(showAnim);
}
 
源代码6 项目: dttv-android   文件: SlideTabsFragment.java
private void startAniation(View v) {
      TranslateAnimation animation = new TranslateAnimation(
              currentIndicatorLeft, v.getLeft(), 0f, 0f);
      animation.setInterpolator(new LinearInterpolator());
      animation.setDuration(100);
      animation.setFillAfter(true);
      iv_nav_indicator.setAnimation(animation);
      iv_nav_indicator.startAnimation(animation);
      currentIndicatorLeft = v.getLeft();
      /*animation.setAnimationListener(new AnimationListener() {
	@Override
	public void onAnimationStart(Animation animation) {
		// TODO Auto-generated method stub
		Log.i(TAG, "enter onAnimationStart");
	}

	@Override
	public void onAnimationRepeat(Animation animation) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onAnimationEnd(Animation animation) {
		// TODO Auto-generated method stub
		Log.i(TAG, "enter onAnimationEnd");
	}
});*/
  }
 
源代码7 项目: JianshuApp   文件: SmartSwitchButton.java
private void startAnim() {
    this.isPlayingAnim = true;
    int distance = this.mLine.getMeasuredWidth() - this.mCircle.getMeasuredWidth();
    TranslateAnimation anim = new TranslateAnimation(0.0f, this.isChecked ? (float) (-distance) : (float) distance, 0.0f, 0.0f);
    anim.setDuration(40);
    anim.setFillAfter(false);
    anim.setAnimationListener(this);
    this.mCircle.startAnimation(anim);
}
 
public EditTextShakeHelper(Context context) {

        // 初始化振动器
        shakeVibrator = (Vibrator) context
                .getSystemService(Service.VIBRATOR_SERVICE);
        // 初始化震动动画
        shakeAnimation = new TranslateAnimation(0, 10, 0, 0);
        shakeAnimation.setDuration(300);
        cycleInterpolator = new CycleInterpolator(8);
        shakeAnimation.setInterpolator(cycleInterpolator);

    }
 
源代码9 项目: Auie   文件: UIActionSheetDialog.java
/**
 * 展示控件
 */
public void show() {
	builder();
	setSheetItems();
	AlphaAnimation animation1 = new AlphaAnimation(0.3f, 1.0f);
	animation1.setDuration(200);
	TranslateAnimation animation = new TranslateAnimation(0, 0, HEIGHT, 0);
	animation.setDuration(320);
	rootLayout.startAnimation(animation1);
	parentLayout.startAnimation(animation);
	showAtLocation(((ViewGroup)(((Activity) context).findViewById(android.R.id.content))).getChildAt(0), Gravity.BOTTOM, 0, 0);
}
 
源代码10 项目: POCenter   文件: PlatformPage.java
private void initAnims() {
	animShow = new TranslateAnimation(
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 1,
			Animation.RELATIVE_TO_SELF, 0);
	animShow.setDuration(300);

	animHide = new TranslateAnimation(
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 1);
	animHide.setDuration(300);
}
 
源代码11 项目: BigApp_Discuz_Android   文件: PlatformListPage.java
private void initAnim() {
	animShow = new TranslateAnimation(
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 1,
			Animation.RELATIVE_TO_SELF, 0);
	animShow.setDuration(300);

	animHide = new TranslateAnimation(
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 1);
	animHide.setDuration(300);
}
 
源代码12 项目: DoraemonKit   文件: BottomUpWindow.java
public BottomUpWindow show(View parent) {
    this.showAtLocation(parent, Gravity.BOTTOM
            | Gravity.CENTER_HORIZONTAL, 0, 0);
    ll_panel.setVisibility(View.VISIBLE);
    //动画
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
    animation.setDuration(200);
    ll_panel.startAnimation(animation);
    if (associationView != null) {
        associationView.onShow();
    }
    return this;
}
 
源代码13 项目: bither-android   文件: ShowFullScreenQrView.java
public void hideToFromView() {
	if (vFrom != null) {
		AlphaAnimation animAlpha = new AlphaAnimation(1, 0);
		animAlpha.setDuration(AnimationDuration);
		vMask.startAnimation(animAlpha);
		int x = 0;
		int y = (screenHeight - statusBarHeight - screenWidth) / 2
				+ statusBarHeight;
		int[] location = new int[2];
		vFrom.getLocationInWindow(location);
		int toX = location[0];
		int toY = location[1];
		float scale = (float) vFrom.getWidth()
				/ (float) UIUtil.getScreenWidth();
		ScaleAnimation animScale = new ScaleAnimation(1, scale, 1, scale);
		animScale.setDuration(AnimationDuration);
		TranslateAnimation animTrans = new TranslateAnimation(0, toX - x,
				0, toY - y);
		animTrans.setDuration(AnimationDuration);
		AnimationSet animSet = new AnimationSet(true);
		animSet.addAnimation(animScale);
		animSet.addAnimation(animTrans);
		flImages.startAnimation(animSet);
		postDelayed(new Runnable() {
			@Override
			public void run() {
				setVisibility(View.GONE);
			}
		}, AnimationDuration);
	} else {
		setVisibility(View.GONE);
	}
}
 
源代码14 项目: appcan-android   文件: EUExWidget.java
private void showLoadingPage(WidgetConfigVO configVO, EBrowserWindow curWind) {
    LayoutInflater layoutInflater = LayoutInflater.from(mContext);
    inflate = (LinearLayout) layoutInflater.inflate(EUExUtil.getResLayoutID("platform_mp_window_middle_loadding"), null);
    inflate.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
    ImageView platform_mp_loadding_close = (ImageView) inflate.findViewById(EUExUtil.getResIdID("platform_mp_loadding_close"));
    TextView platformName = (TextView) inflate.findViewById(EUExUtil.getResIdID("platform_mp_loadding_iconname"));
    platformName.setText(configVO.widgetName);
    platform_mp_loadding_close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //回调前端方法去关闭子应用
            callBackPluginJs("uexWidget.cbCloseLoading", "0");
            mBrwView.removeView(inflate);
        }
    });
    ImageButton platform_mp_loadding_icon = (ImageButton) inflate.findViewById(EUExUtil.getResIdID("platform_mp_loadding_icon"));
    curWind.showButtonIcon(platform_mp_loadding_icon, configVO.appIcon);
    TranslateAnimation anim = 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);
    anim.setDuration(500);
    inflate.startAnimation(anim);
    ViewGroup.LayoutParams param=new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mBrwView.addView(inflate, -1,param);
    Log.e("TAG", "显示过度界面完成================");
}
 
源代码15 项目: UltimateAndroid   文件: ParallaxListViewHelper.java
@Override
protected void translatePreICS(View view, float offset) {
	TranslateAnimation ta = new TranslateAnimation(0, 0, offset, offset);
	ta.setDuration(0);
	ta.setFillAfter(true);
	view.setAnimation(ta);
	ta.start();
}
 
源代码16 项目: JianDan_OkHttp   文件: EditTextShakeHelper.java
public EditTextShakeHelper(Context context) {

        // 初始化振动器
        shakeVibrator = (Vibrator) context
                .getSystemService(Service.VIBRATOR_SERVICE);
        // 初始化震动动画
        shakeAnimation = new TranslateAnimation(0, 10, 0, 0);
        shakeAnimation.setDuration(300);
        cycleInterpolator = new CycleInterpolator(8);
        shakeAnimation.setInterpolator(cycleInterpolator);

    }
 
源代码17 项目: BaoKanAndroid   文件: DragScrollView.java
public void animation() {
    TranslateAnimation ta = new TranslateAnimation(0, 0, inner.getTop(),
            normal.top);
    ta.setDuration(200);
    inner.startAnimation(ta);
    inner.layout(normal.left, normal.top, normal.right, normal.bottom);
    normal.setEmpty();
}
 
源代码18 项目: Modularity   文件: AnimationUtil.java
/**
 * 位移 Translate
 */
public static Animation getTranslateAnimation(float fromXDelta,
                                              float toXDelta, float fromYDelta, float toYDelta,
                                              long durationMillis) {
    TranslateAnimation translate = new TranslateAnimation(fromXDelta,
            toXDelta, fromYDelta, toYDelta);
    translate.setDuration(durationMillis);
    translate.setFillAfter(true);
    return translate;
}
 
源代码19 项目: Auie   文件: UI2048GameView.java
private TranslateAnimation moveAnimationY(int overY){
	TranslateAnimation animation = new TranslateAnimation(0, 0, cardSize * overY, 0);
	animation.setDuration(120 * Math.abs(overY));
	return animation;
}
 
源代码20 项目: letv   文件: ChannelFragmentAdapter.java
private TranslateAnimation getTranslateAnimator(float targetX, float targetY) {
    TranslateAnimation translateAnimation = new TranslateAnimation(1, 0.0f, 0, targetX, 1, 0.0f, 0, targetY);
    translateAnimation.setDuration(ANIM_TIME);
    translateAnimation.setFillAfter(true);
    return translateAnimation;
}