List of usage examples for android.view.animation Animation ABSOLUTE
int ABSOLUTE
To view the source code for android.view.animation Animation ABSOLUTE.
Click Source Link
From source file:Main.java
public static Animation getUpAnimation(int height) { Animation animation = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, height, Animation.ABSOLUTE, 0); animation.setDuration(800);//from w w w . j a va2s. c om // animation.setFillAfter(true); return animation; }
From source file:Main.java
private static TranslateAnimation getTranslateX100To0Animation(View view, long duration) { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); animation.setDuration(duration);/*from w ww . ja v a 2s . c o m*/ return animation; }
From source file:Main.java
private static TranslateAnimation getTranslateX0To100Animation(View view, long duration) { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); animation.setDuration(duration);//w w w .ja v a 2 s . co m return animation; }
From source file:Main.java
public static void showViewFromBottom(View view) { if (view.getVisibility() == View.VISIBLE) { return;/*from ww w. j a v a2 s . c o m*/ } view.setVisibility(View.VISIBLE); int height = view.getHeight(); TranslateAnimation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, height, Animation.ABSOLUTE, 0); translateAnimation.setDuration(ANIMATION_DURATION); translateAnimation.setInterpolator(sAnimationInterpolator); view.startAnimation(translateAnimation); }
From source file:Main.java
public static void startScaleAnimationOn(View view, float startScale, float endScale, long duration) { Animation anim = new ScaleAnimation(1f, 1f, startScale, endScale, Animation.ABSOLUTE, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); anim.setDuration(duration);// w ww . j a va 2s.c om anim.setFillAfter(true); view.startAnimation(anim); }
From source file:Main.java
/** * Get translate animation of PathButton.<br> * The visibility of path button and anchor view must be * {@link View#VISIBLE} or {@link View#INVISIBLE}. * * @param isOpen Is open for button/*from w ww .j a v a2s . c om*/ * @param button Path button * @param anchor Control button * @return Animation */ public static Animation animOfPathButton(boolean isOpen, View button, View anchor) { int[] anchorL = new int[2]; anchor.getLocationOnScreen(anchorL); int[] buttonL = new int[2]; button.getLocationOnScreen(buttonL); int x = anchorL[0] - buttonL[0] + (anchor.getWidth() - button.getWidth()) / 2; int y = anchorL[1] - buttonL[1] + (anchor.getHeight() - button.getHeight()) / 2; TranslateAnimation anim = new TranslateAnimation(Animation.ABSOLUTE, isOpen ? x : 0, Animation.ABSOLUTE, isOpen ? 0 : x, Animation.ABSOLUTE, isOpen ? y : 0, Animation.ABSOLUTE, isOpen ? 0 : y); anim.setDuration(300); anim.setFillAfter(true); return anim; }
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//from ww w .j ava 2s . c o 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.emmasuzuki.quickreturnlistview.view.QuickReturnListView.java
private void animateQuickReturnViewToDest(final int destY) { // Pre-honeycomb style Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, destY - mQuickReturnView.getTop()); animation.setFillEnabled(true);/* ww w. j av a 2 s .co m*/ animation.setDuration(mSettleAnimationDuration); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { // Noop } @Override public void onAnimationEnd(Animation animation) { // TranslateAnimation does not change view's position, so // after the animation end, manually set quick return view position to destination setQuickReturnViewY(destY); } @Override public void onAnimationRepeat(Animation animation) { // Noop } }); mQuickReturnView.startAnimation(animation); }
From source file:de.grobox.transportr.trips.search.DirectionsFragment.java
private void swapLocations() { float toToY = fromCard.getY() - toCard.getY(); Animation slideUp = new TranslateAnimation(RELATIVE_TO_SELF, 0.0f, RELATIVE_TO_SELF, 0.0f, RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, toToY); slideUp.setDuration(400);//w w w . ja v a 2 s.co m slideUp.setFillAfter(true); slideUp.setFillEnabled(true); float fromToY = toCard.getY() - fromCard.getY(); Animation slideDown = new TranslateAnimation(RELATIVE_TO_SELF, 0.0f, RELATIVE_TO_SELF, 0.0f, RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, fromToY); slideDown.setDuration(400); slideDown.setFillAfter(true); slideDown.setFillEnabled(true); fromCard.startAnimation(slideDown); toCard.startAnimation(slideUp); slideUp.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // swap location objects WrapLocation tmp = to.getLocation(); if (from.isSearching()) { viewModel.findGpsLocation.setValue(null); // TODO: GPS currently only supports from location, so don't swap it for now viewModel.setToLocation(null); } else { viewModel.setToLocation(from.getLocation()); } viewModel.setFromLocation(tmp); fromCard.clearAnimation(); toCard.clearAnimation(); viewModel.search(); } }); }
From source file:com.juick.android.ThreadFragment.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public boolean onTouch(View view, MotionEvent event) { if (parent.onListTouchEvent(view, event)) return true; if (parent.isFinishing()) return true; if (mScaleDetector != null) { try {//from w ww.j av a2 s. c o m mScaleDetector.onTouchEvent(event); } catch (Exception e) { // shit happens there inside } } try { MotionEvent.PointerCoords pc = new MotionEvent.PointerCoords(); event.getPointerCoords(0, pc); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (navMenu != null && navMenu.getVisibility() == View.VISIBLE) { int[] listViewLocation = new int[2]; int[] imageLocation = new int[2]; getListView().getLocationOnScreen(listViewLocation); navMenu.getLocationOnScreen(imageLocation); imageLocation[0] += navMenu.initialTranslationX; float touchX = pc.x + listViewLocation[0] - imageLocation[0]; float touchY = pc.y + listViewLocation[1] - imageLocation[1]; System.out.println("TOUCH: ACTION_DOWN: x=" + pc.x + " y=" + pc.y); if (touchX > -20 && touchX < navMenu.getWidth() && touchY > 0 && touchY < navMenu.getHeight() * 1.5) { // extra Y pixels due to picture not balanced touchOriginX = pc.x; touchOriginY = pc.y; System.out.println("TOUCH: OK TOUCH NAVMENU"); return true; } } break; case MotionEvent.ACTION_UP: if (!ignoreMove && !isNavigationMenuShown()) resetMainMenuButton(false); if (touchOriginX > 0 || ignoreMove) { touchOriginX = -1; ignoreMove = false; return true; } break; case MotionEvent.ACTION_MOVE: if (ignoreMove || navMenu == null) return true; event.getPointerCoords(0, pc); double travelledDistance = Math .sqrt(Math.pow(touchOriginX - pc.x, 2) + Math.pow(touchOriginY - pc.y, 2)); boolean inZone = false; if (!isNavigationMenuShown()) { if (touchOriginX >= 0) { // detect angle where finger moves if (travelledDistance < 10) { // grace period inZone = true; } else { float dx = Math.abs(touchOriginX - pc.x); float dy = Math.abs(touchOriginY - pc.y); if (dx > dy) { // movement in 45 degree zone if (touchOriginX > pc.x) { // towards left inZone = true; double neededDistance = 1.5 / 2.54 * getResources().getDisplayMetrics().xdpi; if (travelledDistance > neededDistance) { // moved 1.5 centimeters System.out.println("TOUCH: OPEN MENU"); ignoreMove = true; openNavigationMenu(pc.x - touchOriginX + initNavMenuTranslationX); touchOriginX = -1; } } } else { System.out.println("TOUCH: LEAVING ZONE: dx=" + dx + " dy=" + dy); } } if (inZone && !ignoreMove) { TranslateAnimation immediate = new TranslateAnimation(Animation.ABSOLUTE, pc.x - touchOriginX + initNavMenuTranslationX, Animation.ABSOLUTE, pc.x - touchOriginX + initNavMenuTranslationX, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); immediate.setDuration(5); immediate.setFillAfter(true); immediate.setFillBefore(true); immediate.setFillEnabled(true); navMenu.startAnimation(immediate); } } if (!inZone) { resetMainMenuButton(false); if (touchOriginX >= 0) { System.out.println("TOUCH: ACTION_MOVE: x=" + pc.x + " y=" + pc.y); System.out.println("TOUCH: LEFT ZONE"); touchOriginX = -1; } } if (inZone) { return true; } if (doOnClick != null || ignoreMove) { return true; } } break; } } catch (NoClassDefFoundError err) { // so be it. } return false; }