List of usage examples for android.view.animation RotateAnimation setDuration
public void setDuration(long durationMillis)
From source file:com.example.android.tryanimationt.TryAnimationFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mCardView = (CardView) view.findViewById(R.id.cardview); fab1st = (android.widget.ImageButton) view.findViewById(R.id.fabBt); fab2nd = (android.widget.ImageButton) view.findViewById(R.id.fabBt2); fab3rd = (android.widget.ImageButton) view.findViewById(R.id.fab3); footer = view.findViewById(R.id.footer); animButtons(fab1st, true, 2500, 0);/*from www .j a v a 2s . c om*/ animButtons(fab2nd, true, 1000, 150); animButtons(fab3rd, true, 2000, 250); fab1st.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AnimatorSet animSet = new AnimatorSet(); ObjectAnimator anim2 = ObjectAnimator.ofFloat(fab1st, "rotationX", 0, 359); anim2.setDuration(1500); ObjectAnimator anim3 = ObjectAnimator.ofFloat(fab1st, "rotationY", 0, 359); anim3.setDuration(1500); ObjectAnimator animTrx = ObjectAnimator.ofFloat(fab1st, "translationX", 0, -20); animTrx.setDuration(2500); ObjectAnimator animTry = ObjectAnimator.ofFloat(fab1st, "translationY", 0, -20); animTry.setDuration(2500); animSet.setInterpolator(new BounceInterpolator()); animSet.playTogether(anim2, anim3, animTry, animTrx); animSet.start(); } }); fab1st.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { int size = getResources().getDimensionPixelSize(R.dimen.fab_size); outline.setOval(0, 0, size, size); outline.setRoundRect(0, 0, size, size, size / 2); } }); fab1st.setClipToOutline(true); final View vImage = view.findViewById(R.id.image); final View vCard = view.findViewById(R.id.cardview); final View vCardTextPart = view.findViewById(R.id.cardview_textpart2); final View vCardContentContainer = view.findViewById(R.id.cardContentContainer); vCard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), // Now we provide a list of Pair items which contain the view we can transitioning // from, and the name of the view it is transitioning to, in the launched activity android.support.v4.util.Pair.create(vImage, "photo_hero"), android.support.v4.util.Pair.create(vCardTextPart, "sharedSceneTrasintionText")); Intent intent = new Intent(getActivity(), sceneTransitionActivity.class); intent.putExtra("photo_hero", R.drawable.image1); ActivityCompat.startActivity(getActivity(), intent, options.toBundle()); } }); fab2nd.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { int size = getResources().getDimensionPixelSize(R.dimen.fab_size); outline.setOval(0, 0, size, size); outline.setRoundRect(0, 0, size, size, size / 2); } }); fab2nd.setClipToOutline(true); final AnimationDrawable[] animDrawables = new AnimationDrawable[2]; animDrawables[0] = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_off_to_on); animDrawables[1] = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_on_to_off); animDrawables[0].setOneShot(true); animDrawables[1].setOneShot(true); fab2nd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final int fab2InconIndex = mAnimationStateIndex; mAnimationStateIndex = (mAnimationStateIndex + 1) % 2; /*****************************************************/ // animate the card //final Animation myRotation = AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_anim); //mCardView.startAnimation(myRotation); int start; int end; if (mAnimationStateIndex == 0) { start = Color.rgb(0x71, 0xc3, 0xde); end = Color.rgb(0x68, 0xe8, 0xee); } else { start = Color.rgb(0x68, 0xe8, 0xee); end = Color.rgb(0x71, 0xc3, 0xde); } AnimatorSet animSet = new AnimatorSet(); ValueAnimator valueAnimator = ObjectAnimator.ofInt(vCardContentContainer, "backgroundColor", start, end); valueAnimator.setInterpolator(new BounceInterpolator()); valueAnimator.setDuration(2000); valueAnimator.setEvaluator(new ArgbEvaluator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int animProgress = (Integer) animation.getAnimatedValue(); } }); valueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.setRadius(8); //mCardView.setElevation(0); } }); float rotateStart, rotateEnd; float scaleXStart, scaleXEnd; float rotateXStart, rotateXEnd; float rotateYStart, rotateYEnd; float transitionXStart, transitionXEnd; float transitionYStart, transitionYEnd; if (mAnimationStateIndex == 0) { rotateStart = 0f; rotateEnd = 80f; scaleXStart = 1f; scaleXEnd = 0.66f; rotateXStart = 0f; rotateXEnd = 30f; rotateYStart = 0f; rotateYEnd = 30f; transitionYStart = 0f; transitionYEnd = -100f; transitionXStart = 0f; transitionXEnd = 100f; } else { rotateStart = 80f; rotateEnd = 0f; scaleXStart = 0.66f; scaleXEnd = 1; rotateXStart = 30; rotateXEnd = 0f; rotateYStart = 30f; rotateYEnd = 0f; transitionYStart = -100f; transitionYEnd = 0f; transitionXStart = 100f; transitionXEnd = 0f; } ObjectAnimator anim = ObjectAnimator.ofFloat(mCardView, "rotation", rotateStart, rotateEnd); anim.setDuration(2000); ObjectAnimator anim1 = ObjectAnimator.ofFloat(mCardView, "scaleX", scaleXStart, scaleXEnd); anim1.setDuration(2000); ObjectAnimator anim2 = ObjectAnimator.ofFloat(mCardView, "rotationX", rotateXStart, rotateXEnd); anim2.setDuration(2000); ObjectAnimator anim3 = ObjectAnimator.ofFloat(mCardView, "rotationY", rotateYStart, rotateYEnd); anim3.setDuration(2000); ObjectAnimator animTry = ObjectAnimator.ofFloat(mCardView, "translationY", transitionYStart, transitionYEnd); animTry.setDuration(2000); ObjectAnimator animTrx = ObjectAnimator.ofFloat(mCardView, "translationX", transitionXStart, transitionXEnd); animTrx.setDuration(2000); animSet.setInterpolator(new BounceInterpolator()); animSet.playTogether(valueAnimator, anim, anim2, anim3, anim1, animTry, animTrx); float controlX1, controlY1, controlX2, controlY2; if (mAnimationStateIndex == 0) { controlX1 = 0f; controlY1 = 0.25f; controlX2 = 1; controlY2 = 1; } else { controlX1 = 1; controlY1 = 1; controlX2 = 0.25f; controlY2 = 1; } PathInterpolator pathInterpolator = new PathInterpolator(controlX1, controlY1, controlX2, controlY2); animTrx.setInterpolator(pathInterpolator); animSet.start(); /*****************************************************/ // animate rotate white button RotateAnimation r = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); r.setDuration(2000); r.setFillAfter(true); r.setInterpolator(new BounceInterpolator()); fab2nd.startAnimation(r); // change 2nd button image fab2nd.setImageDrawable(animDrawables[fab2InconIndex]); animDrawables[fab2InconIndex].start(); /*****************************************************/ // animate changing 3rd button image fab3rd.setImageDrawable(animDrawables[mAnimationStateIndex]); animDrawables[mAnimationStateIndex].start(); /*****************************************************/ // using AnimatedStateListDrawable to animate the 1st button image by its state { Drawable drawable = getActivity().getResources().getDrawable(R.drawable.icon_anim); fab1st.setImageDrawable(drawable); final int[] STATE_CHECKED = new int[] { android.R.attr.state_checked }; final int[] STATE_UNCHECKED = new int[] {}; // set state fab1st.setImageState((mAnimationStateIndex != 0) ? STATE_UNCHECKED : STATE_CHECKED, false); drawable.jumpToCurrentState(); // change to state fab1st.setImageState((mAnimationStateIndex != 0) ? STATE_CHECKED : STATE_UNCHECKED, false); } } }); fab3rd.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { int size = getResources().getDimensionPixelSize(R.dimen.fab_size); outline.setOval(0, 0, size, size); outline.setRoundRect(0, 0, size, size, size / 2); } }); fab3rd.setClipToOutline(true); final CheckBox circleFadeout = (CheckBox) view.findViewById(R.id.circleFadeout); circleFadeout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (((CheckBox) v).isChecked()) { } } }); final ImageButton vLogoBt = fab3rd; vLogoBt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { animButtons(fab1st, false, 2000, 0); animButtons(fab2nd, false, 600, 150); animButtons(fab3rd, false, 1500, 250); Handler delayHandler = new Handler(); delayHandler.postDelayed(new Runnable() { @Override public void run() { Intent logoIntent = new Intent(getActivity(), LogoActivity.class); logoIntent.putExtra(LogoActivity.LOGO_VIEW_IMAGE_FADEOUT, (circleFadeout.isChecked() ? 1 : 0)); logoIntent.putExtra(LogoActivity.LOGO_VIEW_TRANSTION_TYPE, logoActivityTransitionType); startActivityForResult(logoIntent, mRequestCode, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle()); } }, 1000); // footer slide down slideView(footer, false); } }); mRadioGrp = (RadioGroup) view.findViewById(R.id.radioGroup); mRadioGrp.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int selectedId = mRadioGrp.getCheckedRadioButtonId(); String transitionType = "using"; switch (selectedId) { case R.id.radioFade: logoActivityTransitionType = 0; transitionType = transitionType + " Fade"; break; case R.id.radioExplode: logoActivityTransitionType = 1; transitionType = transitionType + " Explode"; break; default: logoActivityTransitionType = 2; transitionType = transitionType + " Slide"; } mSwitcher.setText(transitionType + " transition"); } }); mSwitcher = (TextSwitcher) view.findViewById(R.id.textSwitcher); mSwitcher.setFactory(mFactory); Animation in = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_top); Animation out = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_top); mSwitcher.setInAnimation(in); mSwitcher.setOutAnimation(out); mSwitcher.setCurrentText("using Fade transition"); // footer slide up slideView(footer, true); }
From source file:fr.shywim.antoinedaniel.ui.fragment.VideoDetailsFragment.java
private void bindSound(View view, Cursor cursor) { AppState appState = AppState.getInstance(); final View card = view; final View downloadFrame = view.findViewById(R.id.sound_download_frame); final TextView tv = (TextView) view.findViewById(R.id.grid_text); final SquareImageView siv = (SquareImageView) view.findViewById(R.id.grid_image); final ImageView star = (ImageView) view.findViewById(R.id.ic_sound_fav); final ImageView menu = (ImageView) view.findViewById(R.id.ic_sound_menu); final String soundName = cursor .getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_SOUND_NAME)); String imgId = cursor.getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_IMAGE_NAME)); final String description = cursor.getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_DESC)); final boolean favorite = appState.favSounds.contains(soundName) || cursor.getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_FAVORITE)) == 1; final boolean widget = appState.widgetSounds.contains(soundName) || cursor.getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_WIDGET)) == 1; final boolean downloaded = cursor .getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_DOWNLOADED)) != 0; new Handler().post(new Runnable() { @Override/*from w ww . j a v a 2 s . c o m*/ public void run() { ContentValues cv = new ContentValues(); File sndFile = new File(mContext.getExternalFilesDir(null) + "/snd/" + soundName + ".ogg"); if (downloaded && !sndFile.exists()) { cv.put(ProviderContract.SoundEntry.COLUMN_DOWNLOADED, 0); mContext.getContentResolver().update( Uri.withAppendedPath(ProviderConstants.SOUND_DOWNLOAD_NOTIFY_URI, soundName), cv, null, null); } } }); final View.OnClickListener playSound = new View.OnClickListener() { @Override public void onClick(View v) { String category = mContext.getString(R.string.ana_cat_sound); String action = mContext.getString(R.string.ana_act_play); Bundle extras = new Bundle(); extras.putString(SoundFragment.SOUND_TO_PLAY, soundName); extras.putBoolean(SoundFragment.LOOP, SoundUtils.isLoopingSet()); Intent intent = new Intent(mContext, SoundService.class); intent.putExtras(extras); mContext.startService(intent); AnalyticsUtils.sendEvent(category, action, soundName); } }; final View.OnClickListener downloadSound = new View.OnClickListener() { @Override public void onClick(View v) { card.setOnClickListener(null); RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new BounceInterpolator()); animation.setFillAfter(true); animation.setFillEnabled(true); animation.setDuration(1000); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); downloadFrame.findViewById(R.id.sound_download_icon).startAnimation(animation); DownloadService.startActionDownloadSound(mContext, soundName, new SoundUtils.DownloadResultReceiver(new Handler(), downloadFrame, playSound, this)); } }; if (downloaded) { downloadFrame.setVisibility(View.GONE); downloadFrame.findViewById(R.id.sound_download_icon).clearAnimation(); card.setOnClickListener(playSound); } else { downloadFrame.setAlpha(1); downloadFrame.findViewById(R.id.sound_download_icon).setScaleX(1); downloadFrame.findViewById(R.id.sound_download_icon).setScaleY(1); downloadFrame.setVisibility(View.VISIBLE); card.setOnClickListener(downloadSound); } menu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final ImageView menuIc = (ImageView) v; PopupMenu popup = new PopupMenu(mContext, menuIc); Menu menu = popup.getMenu(); popup.getMenuInflater().inflate(R.menu.sound_menu, menu); if (favorite) menu.findItem(R.id.action_sound_fav).setTitle("Retirer des favoris"); if (widget) menu.findItem(R.id.action_sound_wid).setTitle("Retirer du widget"); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_sound_fav: SoundUtils.addRemoveFavorite(mContext, soundName); return true; case R.id.action_sound_wid: SoundUtils.addRemoveWidget(mContext, soundName); return true; /*case R.id.action_sound_add: return true;*/ case R.id.action_sound_ring: SoundUtils.addRingtone(mContext, soundName, description); return true; case R.id.action_sound_share: AnalyticsUtils.sendEvent(mContext.getString(R.string.ana_cat_soundcontext), mContext.getString(R.string.ana_act_weblink), soundName); ClipboardManager clipboard = (ClipboardManager) mContext .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("BAD link", "http://bad.shywim.fr/" + soundName); clipboard.setPrimaryClip(clip); Toast.makeText(mContext, R.string.toast_link_copied, Toast.LENGTH_LONG).show(); return true; case R.id.action_sound_delete: SoundUtils.delete(mContext, soundName); return true; default: return false; } } }); popup.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { menuIc.setColorFilter(mContext.getResources().getColor(R.color.text_caption_dark)); } }); menuIc.setColorFilter(mContext.getResources().getColor(R.color.black)); popup.show(); } }); tv.setText(description); siv.setTag(imgId); if (appState.favSounds.contains(soundName)) { star.setVisibility(View.VISIBLE); } else if (favorite) { star.setVisibility(View.VISIBLE); appState.favSounds.add(soundName); } else { star.setVisibility(View.INVISIBLE); } File file = new File(mContext.getExternalFilesDir(null) + "/img/" + imgId + ".jpg"); Picasso.with(mContext).load(file).placeholder(R.drawable.noimg).fit().into(siv); }
From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java
protected void createLocationPanelView(final IGISApplication app) { if (null == mGeometry && mFeatureId == NOT_FOUND) { mLatView = (TextView) findViewById(R.id.latitude_view); mLongView = (TextView) findViewById(R.id.longitude_view); mAltView = (TextView) findViewById(R.id.altitude_view); mAccView = (TextView) findViewById(R.id.accuracy_view); final ImageButton refreshLocation = (ImageButton) findViewById(R.id.refresh); mAccurateLocation = (SwitchCompat) findViewById(R.id.accurate_location); mAccurateLocation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override// w w w. ja v a2 s. c o m public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (mAccurateLocation.getTag() == null) { refreshLocation.performClick(); mAccurateLocation.setTag(new Object()); } } }); mAccuracyCE = (AppCompatSpinner) findViewById(R.id.accurate_ce); refreshLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(500); rotateAnimation.setRepeatCount(1); refreshLocation.startAnimation(rotateAnimation); if (mAccurateLocation.isChecked()) { AlertDialog.Builder builder = new AlertDialog.Builder(ModifyAttributesActivity.this); View layout = View.inflate(ModifyAttributesActivity.this, R.layout.dialog_progress_accurate_location, null); TextView message = (TextView) layout.findViewById(R.id.message); final ProgressBar progress = (ProgressBar) layout.findViewById(R.id.progress); final TextView progressPercent = (TextView) layout.findViewById(R.id.progress_percent); final TextView progressNumber = (TextView) layout.findViewById(R.id.progress_number); final CheckBox finishBeep = (CheckBox) layout.findViewById(R.id.finish_beep); builder.setView(layout); builder.setTitle(R.string.accurate_location); final AccurateLocationTaker accurateLocation = new AccurateLocationTaker(view.getContext(), 100f, mMaxTakeCount, MAX_TAKE_TIME, PROGRESS_DELAY, (String) mAccuracyCE.getSelectedItem()); progress.setIndeterminate(true); message.setText(R.string.accurate_taking); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { accurateLocation.cancelTaking(); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { accurateLocation.cancelTaking(); } }); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { ControlHelper.unlockScreenOrientation(ModifyAttributesActivity.this); } }); final AlertDialog dialog = builder.create(); accurateLocation .setOnProgressUpdateListener(new AccurateLocationTaker.OnProgressUpdateListener() { @SuppressLint("SetTextI18n") @Override public void onProgressUpdate(Long... values) { int value = values[0].intValue(); if (value == 1) { progress.setIndeterminate(false); progress.setMax(mMaxTakeCount); } if (value > 0) progress.setProgress(value); progressPercent.setText(value * 100 / mMaxTakeCount + " %"); progressNumber.setText(value + " / " + mMaxTakeCount); } }); accurateLocation.setOnGetAccurateLocationListener( new AccurateLocationTaker.OnGetAccurateLocationListener() { @Override public void onGetAccurateLocation(Location accurateLocation, Long... values) { dialog.dismiss(); if (finishBeep.isChecked()) playBeep(); setLocationText(accurateLocation); } }); ControlHelper.lockScreenOrientation(ModifyAttributesActivity.this); dialog.setCanceledOnTouchOutside(false); dialog.show(); accurateLocation.startTaking(); } else if (null != app) { GpsEventSource gpsEventSource = app.getGpsEventSource(); Location location = gpsEventSource.getLastKnownLocation(); setLocationText(location); } } }); } else { //hide location panel ViewGroup rootView = (ViewGroup) findViewById(R.id.controls_list); rootView.removeView(findViewById(R.id.location_panel)); } }
From source file:com.geecko.QuickLyric.fragment.LocalLyricsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { final MainActivity mainActivity = ((MainActivity) this.getActivity()); super.onViewCreated(view, savedInstanceState); if (this.isHidden()) return;//w w w.j a v a2 s. co m DrawerAdapter drawerAdapter = ((DrawerAdapter) ((ListView) mainActivity.findViewById(R.id.drawer_list)) .getAdapter()); if (drawerAdapter.getSelectedItem() != 1) { drawerAdapter.setSelectedItem(1); drawerAdapter.notifyDataSetChanged(); } if (!megaListView.hasOnGroupClickListener()) megaListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { final ImageView indicator = (ImageView) v.findViewById(R.id.group_indicator); RotateAnimation anim; if (megaListView.isGroupExpanded(groupPosition)) { megaListView.collapseGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(180f, 360f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(3)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } else { megaListView.expandGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(0f, 180f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(2)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } return true; } }); if (!megaListView.hasOnChildClickListener()) megaListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mSwiping) { mSwiping = false; return false; } final MainActivity mainActivity = (MainActivity) getActivity(); megaListView.setOnChildClickListener(null); // prevents bug on double tap mainActivity.updateLyricsFragment(R.animator.slide_out_start, R.animator.slide_in_start, true, ((LocalAdapter) megaListView.getExpandableListAdapter()).getChild(groupPosition, childPosition)); return true; } }); this.isActiveFragment = true; new DBContentLister(this).execute(); }
From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java
@Override public void onSensorChanged(SensorEvent event) { // get the angle around the z-axis rotated float degree = Math.round(event.values[0]); //tvHeading.setText("Heading: " + Float.toString(degree) + " degrees"); // create a rotation animation (reverse turn degree degrees) RotateAnimation ra = new RotateAnimation(currentDegree, degree, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // how long the animation will take place ra.setDuration(210); // set the animation after the end of the reservation status ra.setFillAfter(true);//from ww w. ja v a2 s . com // Start the animation image.startAnimation(ra); currentDegree = degree; editTextAngle.setText("AngleM : " + currentDegree + " DistM : " + distance + " GPSDir " + gpsDirection + " Dif " + diference + " Ponto " + index); }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public ImageView.OnLayoutChangeListener hourglasslistener() { OnLayoutChangeListener olcl = new ImageView.OnLayoutChangeListener() { @Override//w ww . ja v a2s. c o m public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { RotateAnimation animation = new RotateAnimation(0f, 350f, v.getWidth() / 2, v.getHeight() / 2); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setDuration(700); ((ImageView) v).startAnimation(animation); } }; return olcl; }