List of usage examples for android.view.animation Animation RELATIVE_TO_SELF
int RELATIVE_TO_SELF
To view the source code for android.view.animation Animation RELATIVE_TO_SELF.
Click Source Link
From source file:com.capricorn.ArcMenu.java
private static Animation createHintSwitchAnimation(final boolean expanded) { Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setStartOffset(0);//from ww w . j a va 2s .c om animation.setDuration(100); animation.setInterpolator(new DecelerateInterpolator()); animation.setFillAfter(true); return animation; }
From source file:org.runbuddy.tomahawk.views.PageIndicator.java
private void rotateArrow(View arrow, boolean reverse) { RotateAnimation rotate;// ww w .ja v a2 s. co m if (reverse) { rotate = new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); } else { rotate = new RotateAnimation(360, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); } rotate.setDuration(AnimationUtils.DURATION_ARROWROTATE); arrow.startAnimation(rotate); rotate.setFillAfter(true); }
From source file:com.sociablue.nanodegree_p1.MovieListFragment.java
private void initializeFab(View rootView) { final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container); final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab); final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar); final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar); Fab.setOnClickListener(new View.OnClickListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override// w w w.j a v a 2 s .co m public void onClick(View v) { //Menu Button Icon Animation //Setting up necessary variables long animationDuration = 500; float containerHeight = buttonContainer.getHeight(); float containerCenterY = containerHeight / 2; float containerCenterX = buttonContainer.getWidth() / 2; float topBarCenter = topBar.getTop() + topBar.getHeight() / 2; float widthOfBar = topBar.getWidth(); float heightOfBar = topBar.getHeight(); final float distanceBetweenBars = (containerCenterY - topBarCenter); /** *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties *and objects at the same time. Also, will try to break intialization into smaller functions. */ //Setting up animations of hamburger bars and rotation /** * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar. * Y Translation is 1/2 the height of the hamburger bar minus the distance. * Subtracting the distance from the height because the distance between bars is * calculated of the exact center of the button. * With out the subtraction the bar would translate slightly below the middle bar. */ float yTranslation = heightOfBar / 2 - distanceBetweenBars; float xTranslation = widthOfBar / 2 + heightOfBar / 2; TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars); topBarTranslationAnim.setDuration((long) (animationDuration * 0.8)); topBarTranslationAnim.setFillAfter(true); //Animation for bottom hamburger bar. Translates and Rotates to create 'X' AnimationSet bottomBarAnimation = new AnimationSet(true); bottomBarAnimation.setFillAfter(true); //Rotate to create cross. (The cross becomes the X after the button rotation completes" RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f); bottomBarRotationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarRotationAnimation); //Translate to correct X alignment TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -yTranslation); bottomBarTranslationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarTranslationAnimation); //Button Specific Animations //Rotate Button Container RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); containerRotationAnimation.setDuration(animationDuration); containerRotationAnimation.setFillAfter(true); //Animate change of button color between Active and Disabled colors that have been //defined in color.xml int activeColor = getResources().getColor(R.color.active_button); int disabledColor = getResources().getColor(R.color.disabled_button); //Need to use ValueAnimator because property animator does not support BackgroundTint ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor); buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue())); } }); buttonColorAnimation.setDuration(animationDuration); //Start all the animations topBar.startAnimation(topBarTranslationAnim); bottomBar.startAnimation(bottomBarAnimation); buttonContainer.startAnimation(containerRotationAnimation); buttonColorAnimation.start(); //Toogle mMenu open and closed if (mMenu.isOpen()) { //If mMenu is open, do the reverse of the animation containerRotationAnimation .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator())); mMenu.close(); } else { bottomBarAnimation.setInterpolator(new AccelerateInterpolator()); mMenu.open(); } } }); }
From source file:com.justwayward.reader.ui.activity.SubjectBookListActivity.java
private void hideTagGroup() { Animation mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f);//from w w w . ja v a 2s. c om mHiddenAction.setDuration(400); rsvTags.startAnimation(mHiddenAction); rsvTags.setVisibility(View.GONE); }
From source file:com.aniruddhc.acemusic.player.FoldersFragment.FilesFoldersFragment.java
/** * Slides in the ListView./*from www. j a v a 2s .c om*/ */ private void slideUpListView() { getDir(rootDir, null); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(600); animation.setInterpolator(new AccelerateDecelerateInterpolator()); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation arg0) { listView.setVisibility(View.VISIBLE); } }); listView.startAnimation(animation); }
From source file:com.capricorn.ArcMenu.java
private static Animation createQuickHintSwitchAnimation(final boolean expanded) { Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setStartOffset(0);// w w w .j a va2s .c o m animation.setDuration(10); animation.setInterpolator(new DecelerateInterpolator()); animation.setFillAfter(true); return animation; }
From source file:com.javadog.cgeowear.CompassActivity.java
/** * Handles rotation of the compass to a new direction. * * @param newDirectionRaw Direction to turn to, in degrees. *///from w w w. j av a2 s . c om private void rotateCompass(final float newDirectionRaw) { //Rotate through smallest angle float apparent; apparent = newRot % 360; if (apparent < 0) { apparent += 360; } if (apparent < 180 && (newDirectionRaw > (apparent + 180))) { newRot -= 360; } if (apparent >= 180 && (newDirectionRaw <= (apparent - 180))) { newRot += 360; } newRot += (newDirectionRaw - apparent); if (currentRotation != newDirectionRaw) { RotateAnimation anim = new RotateAnimation(currentRotation, newRot, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); anim.setDuration(200l); anim.setFillAfter(true); iv_compass.startAnimation(anim); currentRotation = newRot; } }
From source file:com.cyj.ui.component.listview.CusSwipeRefreshLayout.java
private void addDefaultHeadView(Context context) { mHeadView = LayoutInflater.from(context).inflate(R.layout.default_listview_header, null); mRefreshImageview = (ImageView) mHeadView.findViewById(R.id.pull_to_refresh_image); mRefreshTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_text); mRefreshSubTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_sub_text); mRefreshProgress = (ProgressBar) mHeadView.findViewById(R.id.pull_to_refresh_progress); addView(mHeadView, 0);//from ww w. java 2s. c o m mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setDuration(150); mRotateAnimation.setFillAfter(true); mIsDefaultHeadView = true; }
From source file:com.cleanwiz.applock.ui.activity.LockMainActivity.java
private void initAnim() { long duration = 300; long durationS = 160; float alpha = 0.3f; AccelerateInterpolator accInterpolator = new AccelerateInterpolator(); tab_left = new TranslateAnimation(tabW, 0, 0, 0); tab_right = new TranslateAnimation(0, tabW, 0, 0); tab_alpha_1 = new AlphaAnimation(1.0f, alpha); tab_alpha_2 = new AlphaAnimation(alpha, 1.0f); pop_in = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_out = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_in.setDuration(durationS);/*from w ww. j av a2 s .com*/ pop_in.setInterpolator(accInterpolator); pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN)); pop_out.setDuration(durationS); pop_out.setInterpolator(accInterpolator); pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT)); tab_left.setFillAfter(true); tab_left.setFillEnabled(true); tab_left.setDuration(duration); tab_left.setInterpolator(accInterpolator); tab_right.setFillAfter(true); tab_right.setFillEnabled(true); tab_right.setDuration(duration); tab_right.setInterpolator(accInterpolator); tab_alpha_1.setFillAfter(true); tab_alpha_1.setFillEnabled(true); tab_alpha_1.setDuration(duration); tab_alpha_1.setInterpolator(accInterpolator); tab_alpha_2.setFillAfter(true); tab_alpha_2.setFillEnabled(true); tab_alpha_2.setDuration(duration); tab_alpha_2.setInterpolator(accInterpolator); AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha); alphaInit.setFillAfter(true); alphaInit.setFillEnabled(true); tv_tab_box.startAnimation(alphaInit); }
From source file:com.aniruddhc.acemusic.player.ListViewFragment.ListViewFragment.java
/** * Displays the search field.//ww w . j a va 2s .c o m */ private void showSearch() { mSearchLayout.setVisibility(View.VISIBLE); final TranslateAnimation searchAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -2f, Animation.RELATIVE_TO_SELF, 0f); searchAnim.setDuration(500l); searchAnim.setInterpolator(new AccelerateDecelerateInterpolator()); final TranslateAnimation gridListAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 2f); gridListAnim.setDuration(500l); gridListAnim.setInterpolator(new LinearInterpolator()); gridListAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mListView.setAdapter(null); } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { mSearchLayout.startAnimation(searchAnim); mSearchLayout.setVisibility(View.VISIBLE); } }); searchAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mSearchEditText.requestFocus()) { mFragment.getActivity().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } }); mListView.startAnimation(gridListAnim); }