List of usage examples for android.view.animation AnimationSet AnimationSet
public AnimationSet(boolean shareInterpolator)
From source file:com.sahildave.snackbar.SnackBar.java
private AnimationSet getExitAnimation() { //Out//from w w w .j a v a2 s . c o m mOutAnimationSet = new AnimationSet(false); TranslateAnimation mSlideOutAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f); mSlideOutAnimation.setFillAfter(true); AlphaAnimation mFadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); mFadeOutAnimation.setFillAfter(true); mOutAnimationSet.addAnimation(mSlideOutAnimation); mOutAnimationSet.addAnimation(mFadeOutAnimation); mOutAnimationSet.setDuration(OUT_ANIMATION_DURATION); return mOutAnimationSet; }
From source file:com.money.manager.ex.fragment.HomeFragment.java
public LayoutAnimationController setAnimationView(View view) { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(250);//from w w w .j a va2 s .co m set.addAnimation(animation); animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(150); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f); return controller; }
From source file:com.sonvp.tooltip.Tooltip.java
@Override public boolean onPreDraw() { container.getViewTreeObserver().removeOnPreDrawListener(this); Context context = container.getContext(); if (!(context instanceof Activity)) { return false; }/*from w ww. ja va 2 s . c om*/ DisplayMetrics displayMetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int displayWidth = displayMetrics.widthPixels; int displayHeight = displayMetrics.heightPixels; int displayTop = getStatusBarHeight(); int anchorTop = rectAnchorView.top; int anchorLeft = rectAnchorView.left; int anchorWidth = anchorView.getWidth(); int anchorHeight = anchorView.getHeight(); int textWidth = viewTooltip.getWidth(); //default height 1 line int textHeight = viewTooltip.getHeight(); int arrowWidth = arrow.getWidth(); int arrowHeight = arrow.getHeight(); int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(displayWidth, View.MeasureSpec.AT_MOST); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); if (gravity == Gravity.TOP || gravity == Gravity.BOTTOM) { int width = Math.max(textWidth, arrowWidth); int height = textHeight + arrowHeight; int leftPadding; int topPadding; if (gravity == Gravity.TOP) { topPadding = anchorTop - height; } else { // gravity == Gravity.BOTTOM topPadding = anchorTop + anchorHeight; } int anchorHorizontalCenter = anchorLeft + anchorWidth / 2; int left = anchorHorizontalCenter - width / 2; int right = left + width; leftPadding = Math.max(0, right > displayWidth ? displayWidth - width : left); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams(); layoutParams.leftMargin = anchorHorizontalCenter - leftPadding - arrowWidth / 2; arrow.setLayoutParams(layoutParams); popupWindow.update(leftPadding, topPadding, container.getWidth(), container.getHeight()); pivotX = width / 2; pivotY = gravity == Gravity.TOP ? height : 0; } else { // gravity == Gravity.LEFT || gravity == Gravity.RIGHT int width = textWidth + arrowWidth; int leftPadding; int topPadding; int rightPadding = 0; if (gravity == Gravity.LEFT) { leftPadding = Math.max(0, anchorLeft - width); leftPadding += (int) builder.toolTipMargin; rightPadding = displayWidth - anchorLeft; } else { // gravity == Gravity.RIGHT leftPadding = anchorLeft + anchorWidth; rightPadding = (int) builder.toolTipMargin; } if (viewTooltip instanceof TextView) { TextView text = (TextView) viewTooltip; text.setMaxWidth(displayWidth - rightPadding - leftPadding - arrowWidth); viewTooltip.measure(widthMeasureSpec, heightMeasureSpec); textHeight = viewTooltip.getMeasuredHeight(); // height multi line } int height = Math.max(textHeight, arrowHeight); int anchorVerticalCenter = anchorTop + anchorHeight / 2; int top = anchorVerticalCenter - height / 2; int bottom = top + height; if (builder.arrowGravity == Gravity.TOP) { top = anchorTop; bottom = anchorTop + height; } else if (builder.arrowGravity == Gravity.BOTTOM) { top = anchorTop + anchorHeight - height; } topPadding = Math.max(0, bottom > displayHeight ? displayHeight - height - (int) builder.toolTipMargin : top); topPadding = Math.max(0, topPadding < displayTop ? displayTop + (int) builder.toolTipMargin : topPadding); container.measure(widthMeasureSpec, heightMeasureSpec); int popupWidth = container.getMeasuredWidth(); int popupHeight = container.getMeasuredHeight(); popupWindow.update(leftPadding, topPadding, popupWidth, popupHeight); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams(); layoutParams.topMargin = anchorVerticalCenter - topPadding - arrowHeight / 2; arrow.setLayoutParams(layoutParams); pivotX = gravity == Gravity.LEFT ? popupWidth : 0; pivotY = anchorVerticalCenter - topPadding; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { container.setAlpha(0.0F); container.setPivotX(pivotX); container.setPivotY(pivotY); container.setScaleX(0.0F); container.setScaleY(0.0F); container.animate().setDuration(ANIMATION_DURATION).scaleX(1.0F).scaleY(1.0F).alpha(1.0F); } else { AnimationSet animationSet = new AnimationSet(true); animationSet.setDuration(ANIMATION_DURATION); animationSet.addAnimation(new AlphaAnimation(0.0F, 1.0F)); animationSet.addAnimation(new ScaleAnimation(0.0F, 1.0F, 0.0F, 1.0F, pivotX, pivotY)); container.startAnimation(animationSet); } return false; }
From source file:com.acceleratedio.pac_n_zoom.AnimActivity.java
private void mainAnmLoop() { AnimationSet anmSet = null;/*w ww.j a v a2s .co m*/ if (onClickFlg == 1) { if (anmSet != null) { anmSet.cancel(); anmSet.reset(); } return; } // --- Loop through the frames int frm_nmbr = svg_data.frm.size(); if (++frm_mbr >= frm_nmbr) frm_mbr = 0; // -- You need to turn the sprites on and off for the current frame LoadSVG.frame crt_frm = svg_data.frm.get(frm_mbr); String crt_frm_ordr = crt_frm.frm_ordr; ArrayList<String> sprt_ordr = svg_data.svg.ordr; int crt_dur = crt_frm.end - crt_frm.bgn; // - Loop through the sprites int sprt_nmbr = sprt_ordr.size(); int frm_sprt_mbr = 0; for (int sprt_mbr = 0; sprt_mbr < sprt_nmbr; sprt_mbr += 1) { String sprt_id = sprt_ordr.get(sprt_mbr); int sym_mbr = Integer.parseInt(sprt_id.substring(1, sprt_id.indexOf('_'))) - 2; if (sym_mbr >= 0) { // not g1 which is not loaded LoadSVG.symbol crt_sym = svg_data.symbl.get(sym_mbr); if (crt_frm_ordr.indexOf(sprt_id) >= 0) { // Sprite is present if (crt_sym.aud_id != null && !crt_sym.aud_id.equals("")) { // The sprite is audio SoundPool mSoundPool = loadSVG.getMSoundPool(); int streamId = mSoundPool.play(svg_data.soundId[sym_mbr], 1.0f, 1.0f, 1, 0, 1.0f); mSoundPool.setLoop(streamId, -1); } else { // The sprite is graphic anim_view = anmViews.get(sprt_mbr); anim_view.setAlpha(1f); int xfm_idx = crt_frm.xfm_idx[frm_sprt_mbr]; if (xfm_idx >= 0) { // An animation tag is present anmSet = new AnimationSet(false); LoadSVG.xfrm crt_xfm = svg_data.xfm.get(xfm_idx); ArrayList<Integer[]> pnts = crt_xfm.mov_path; int init_scl = (int) (initScl[sprt_mbr] * 100); if (pnts.size() > 0) { final Path path = new Path(); ld_scl_pth_pnts(pnts, path); PathAnimation pthAnm = new PathAnimation(path); pthAnm.setDuration(crt_dur); pthAnm.setInterpolator(new LinearInterpolator()); pthAnm.setFillAfter(true); // Needed to keep the result of the animation anmSet.addAnimation(pthAnm); } if (crt_xfm.scl_bgn != init_scl) { float crt_scl = crt_xfm.scl_bgn / init_scl; float end_scl = crt_scl; if (crt_xfm.scl_end != crt_xfm.scl_bgn) end_scl = crt_xfm.scl_end / init_scl; ScaleAnimation sclAnm = new ScaleAnimation(crt_scl, end_scl, crt_scl, end_scl, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); sclAnm.setDuration(crt_dur); anmSet.addAnimation(sclAnm); } if (crt_xfm.rot_bgn != 0) { float crt_rot = crt_xfm.rot_bgn; float end_rot = crt_rot; if (crt_xfm.rot_end != crt_xfm.rot_bgn) end_rot = crt_xfm.rot_end; RotateAnimation rotAnm = new RotateAnimation(crt_rot, end_rot, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotAnm.setDuration(crt_dur); anmSet.addAnimation(rotAnm); } anim_view.startAnimation(anmSet); //start animation } } frm_sprt_mbr++; } else { // The sprite is not present if (!(crt_sym.aud_id != null && !crt_sym.aud_id.equals(""))) { // The sprite is graphic anim_view = anmViews.get(sprt_mbr); anim_view.setAlpha(0f); } } } else { // g1 if (crt_frm_ordr.indexOf(sprt_id) >= 0) frm_sprt_mbr++; } } waitDur(crt_dur); }
From source file:de.dmxcontrol.activity.ControlActivity.java
private Dialog createSplashDialog() { Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); dialog.setContentView(R.layout.dialog_splash); ImageView image = (ImageView) dialog.findViewById(R.id.image_splash); image.setImageResource(R.drawable.image_splash); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500);/* www .j a v a2s .co m*/ animation.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); set.addAnimation(animation); animation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1000); animation.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); set.addAnimation(animation); image.setAnimation(set); dismissSplashDelayed(); return dialog; }
From source file:com.PPRZonDroid.MainActivity.java
/** * Refresh block lisst on right/*w w w .j a va 2s . c o m*/ */ private void refresh_block_list() { int i; BlList.clear(); for (i = 0; i < AC_DATA.AircraftData[AC_DATA.SelAcInd].BlockCount; i++) { BlList.add(new BlockModel(AC_DATA.AircraftData[AC_DATA.SelAcInd].AC_Blocks[i].BlName)); } mBlListAdapter.BlColor = AC_DATA.muiGraphics.get_color(AC_DATA.AircraftData[AC_DATA.SelAcInd].AC_Color); mBlListAdapter.SelectedInd = AC_DATA.AircraftData[AC_DATA.SelAcInd].SelectedBlock; AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, +1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(250); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f); BlListView.setLayoutAnimation(controller); mBlListAdapter.notifyDataSetChanged(); }
From source file:com.wenwen.chatuidemo.activity.NewFragment.java
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { AnimationSet _AnimationSet = new AnimationSet(true); TranslateAnimation _TranslateAnimation; if (checkedId == R.id.btn1) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo1), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100);/*www . j a v a 2 s.com*/ mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(1); mRadioButton1.setTextColor(Color.RED); } else if (checkedId == R.id.btn2) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo2), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100); mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(2); } else if (checkedId == R.id.btn3) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo3), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100); mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(3); } else if (checkedId == R.id.btn4) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo4), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100); mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(4); } mCurrentCheckedRadioLeft = getCurrentCheckedRadioLeft(); DebugLog.i("zj", "getCurrentCheckedRadioLeft=" + getCurrentCheckedRadioLeft()); DebugLog.i("zj", "getDimension=" + getResources().getDimension(R.dimen.rdo2)); mHorizontalScrollView.smoothScrollTo( (int) mCurrentCheckedRadioLeft - (int) getResources().getDimension(R.dimen.rdo2), 0); }
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
protected void animateDragged() { View view = imgBarAvatar;// w w w. j a va2s .c o m float x = 0; try { x = imgBarAvatar.getX(); } catch (NoSuchMethodError e) { } if (pager.getCurrentItem() == 0) { btnOptionsColumnsEdit.setVisibility(View.GONE); } else { btnOptionsColumnsEdit.setVisibility(View.VISIBLE); } view.layout(imgBarAvatar.getLeft(), imgBarAvatar.getTop(), imgBarAvatar.getRight(), imgBarAvatar.getBottom()); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, imgBarAvatar.getHeight() * 3 / 4, imgBarAvatar.getWidth() * 3 / 4); scale.setDuration(150); animSet.addAnimation(scale); animSet.setFillEnabled(true); animSet.setFillAfter(true); view.clearAnimation(); view.startAnimation(animSet); showOptionsColumns((int) x, pager.getCurrentItem(), false); }
From source file:com.androzic.MapFragment.java
private void onUpdateNavigationStatus() { if (!application.isNavigating()) return;//from www .jav a 2s. c o m long now = System.currentTimeMillis(); double distance = application.navigationService.navDistance; double bearing = application.navigationService.navBearing; long turn = application.navigationService.navTurn; double vmg = application.navigationService.navVMG; int ete = application.navigationService.navETE; String[] dist = StringFormatter.distanceC(distance, StringFormatter.precisionFormat); String eteString = (ete == Integer.MAX_VALUE) ? getString(R.string.never) : (String) DateUtils.getRelativeTimeSpanString(now + (ete + 1) * 60000, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); String extra = StringFormatter.speedH(vmg) + " | " + eteString; String trnsym = ""; if (turn > 0) { trnsym = "R"; } else if (turn < 0) { trnsym = "L"; turn = -turn; } bearing = application.fixDeclination(bearing); distanceValue.setText(dist[0]); distanceUnit.setText(dist[1]); bearingValue.setText(StringFormatter.angleC(bearing)); turnValue.setText(StringFormatter.angleC(turn) + trnsym); waypointExtra.setText(extra); if (application.navigationService.isNavigatingViaRoute()) { View rootView = getView(); boolean hasNext = application.navigationService.hasNextRouteWaypoint(); if (distance < application.navigationService.navProximity * 3 && !animationSet) { AnimationSet animation = new AnimationSet(true); animation.addAnimation(new AlphaAnimation(1.0f, 0.3f)); animation.addAnimation(new AlphaAnimation(0.3f, 1.0f)); animation.setDuration(500); animation.setRepeatCount(10); rootView.findViewById(R.id.waypointinfo).startAnimation(animation); if (!hasNext) { rootView.findViewById(R.id.routeinfo).startAnimation(animation); } animationSet = true; } else if (animationSet) { rootView.findViewById(R.id.waypointinfo).setAnimation(null); if (!hasNext) { rootView.findViewById(R.id.routeinfo).setAnimation(null); } animationSet = false; } if (application.navigationService.navXTK == Double.NEGATIVE_INFINITY) { xtkValue.setText("--"); xtkUnit.setText("--"); } else { String xtksym = application.navigationService.navXTK == 0 ? "" : application.navigationService.navXTK > 0 ? "R" : "L"; String[] xtks = StringFormatter.distanceC(Math.abs(application.navigationService.navXTK)); xtkValue.setText(xtks[0] + xtksym); xtkUnit.setText(xtks[1]); } double navDistance = application.navigationService.navRouteDistanceLeft(); int eta = application.navigationService.navRouteETE(navDistance); if (eta < Integer.MAX_VALUE) eta += application.navigationService.navETE; String etaString = (eta == Integer.MAX_VALUE) ? getString(R.string.never) : (String) DateUtils.getRelativeTimeSpanString(now + (eta + 1) * 60000, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); extra = StringFormatter.distanceH(navDistance + distance, 1000) + " | " + etaString; routeExtra.setText(extra); } }
From source file:com.chuhan.privatecalc.fragment.os.FragmentManager.java
static Animation makeOpenCloseAnimation(Context context, float startScale, float endScale, float startAlpha, float endAlpha) { AnimationSet set = new AnimationSet(false); ScaleAnimation scale = new ScaleAnimation(startScale, endScale, startScale, endScale, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); scale.setInterpolator(DECELERATE_QUINT); scale.setDuration(ANIM_DUR);//from w ww. j ava2 s . c om set.addAnimation(scale); AlphaAnimation alpha = new AlphaAnimation(startAlpha, endAlpha); alpha.setInterpolator(DECELERATE_CUBIC); alpha.setDuration(ANIM_DUR); set.addAnimation(alpha); return set; }