Java Code Examples for android.view.animation.TranslateAnimation#setDuration()
The following examples show how to use
android.view.animation.TranslateAnimation#setDuration() .
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: UIHelpers.java From CameraV with GNU General Public License v3.0 | 6 votes |
@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); } }
Example 2
Source File: ParallaxRecyclerAdapter.java From android-parallax-recyclerview with Apache License 2.0 | 6 votes |
/** * 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); } }
Example 3
Source File: ClassTabWidget.java From iSCAU-Android with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example 4
Source File: CaptureActivity.java From ZXingProject with MIT License | 6 votes |
@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); }
Example 5
Source File: PlatformListPage.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
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); }
Example 6
Source File: AnimationUtil.java From Modularity with Apache License 2.0 | 5 votes |
/** * 位移 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; }
Example 7
Source File: DragScrollView.java From BaoKanAndroid with MIT License | 5 votes |
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(); }
Example 8
Source File: EditTextShakeHelper.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
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); }
Example 9
Source File: ParallaxListViewHelper.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@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(); }
Example 10
Source File: EUExWidget.java From appcan-android with GNU Lesser General Public License v3.0 | 5 votes |
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", "显示过度界面完成================"); }
Example 11
Source File: ShowFullScreenQrView.java From bither-android with Apache License 2.0 | 5 votes |
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); } }
Example 12
Source File: BottomUpWindow.java From DoraemonKit with Apache License 2.0 | 5 votes |
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; }
Example 13
Source File: PlatformPage.java From POCenter with MIT License | 5 votes |
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); }
Example 14
Source File: UIActionSheetDialog.java From Auie with GNU General Public License v2.0 | 5 votes |
/** * 展示控件 */ 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); }
Example 15
Source File: EditTextShakeHelper.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
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); }
Example 16
Source File: SmartSwitchButton.java From JianshuApp with GNU General Public License v3.0 | 5 votes |
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); }
Example 17
Source File: SlideTabsFragment.java From dttv-android with GNU General Public License v3.0 | 5 votes |
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"); } });*/ }
Example 18
Source File: ViewOperator.java From PLDroidShortVideo with Apache License 2.0 | 5 votes |
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); }
Example 19
Source File: UI2048GameView.java From Auie with GNU General Public License v2.0 | 4 votes |
private TranslateAnimation moveAnimationY(int overY){ TranslateAnimation animation = new TranslateAnimation(0, 0, cardSize * overY, 0); animation.setDuration(120 * Math.abs(overY)); return animation; }
Example 20
Source File: ChannelFragmentAdapter.java From letv with Apache License 2.0 | 4 votes |
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; }