List of usage examples for android.view View setScaleY
public void setScaleY(float scaleY)
From source file:com.comcast.freeflow.core.FreeFlowContainer.java
protected void returnItemToPoolIfNeeded(FreeFlowItem freeflowItem) { View v = freeflowItem.view; v.setTranslationX(0);//from w ww.ja va2s . c o m v.setTranslationY(0); v.setRotation(0); v.setScaleX(1f); v.setScaleY(1f); v.setAlpha(1); viewpool.returnViewToPool(v); }
From source file:arun.com.chromer.browsing.article.view.ElasticDragDismissFrameLayout.java
private void dragScale(int scroll) { if (scroll == 0) return;//from w w w . ja va2 s .c om totalDrag += scroll; View child = getChildAt(0); // track the direction & set the pivot point for scaling // don't double track i.e. if play dragging down and then reverse, keep tracking as // dragging down until they reach the 'natural' position if (scroll < 0 && !draggingUp && !draggingDown) { draggingDown = true; if (shouldScale) child.setPivotY(getHeight()); } else if (scroll > 0 && !draggingDown && !draggingUp) { draggingUp = true; if (shouldScale) child.setPivotY(0f); } // how far have we dragged relative to the distance to perform a dismiss // (01 where 1 = dismiss distance). Decreasing logarithmically as we approach the limit float dragFraction = (float) Math.log10(1 + (Math.abs(totalDrag) / dragDismissDistance)); // calculate the desired translation given the drag fraction float dragTo = dragFraction * dragDismissDistance * dragElasticity; if (draggingUp) { // as we use the absolute magnitude when calculating the drag fraction, need to // re-apply the drag direction dragTo *= -1; } child.setTranslationY(dragTo); if (draggingBackground == null) { draggingBackground = new RectF(); draggingBackground.left = 0; draggingBackground.right = getWidth(); } if (shouldScale) { final float scale = 1 - ((1 - dragDismissScale) * dragFraction); child.setScaleX(scale); child.setScaleY(scale); } // if we've reversed direction and gone past the settle point then clear the flags to // allow the list to get the scroll events & reset any transforms if ((draggingDown && totalDrag >= 0) || (draggingUp && totalDrag <= 0)) { totalDrag = dragTo = dragFraction = 0; draggingDown = draggingUp = false; child.setTranslationY(0f); child.setScaleX(1f); child.setScaleY(1f); } // draw the background above or below the view where it has scrolled at if (draggingUp) { draggingBackground.bottom = getHeight(); draggingBackground.top = getHeight() + dragTo; invalidate(); } else if (draggingDown) { draggingBackground.top = 0; draggingBackground.bottom = dragTo; invalidate(); } dispatchDragCallback(dragFraction, dragTo, Math.min(1f, Math.abs(totalDrag) / dragDismissDistance), totalDrag); }
From source file:com.marshalchen.common.uimodule.freeflow.core.FreeFlowContainer.java
protected void returnItemToPoolIfNeeded(FreeFlowItem freeflowItem) { View v = freeflowItem.view; v.setTranslationX(0);/* ww w . j a va 2 s. c o m*/ v.setTranslationY(0); v.setRotation(0); v.setScaleX(1f); v.setScaleY(1f); v.setAlpha(1); viewpool.returnViewToPool(v); }
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
private void selectActionFab(boolean animation) { if (null == mFabLayout || null == mSearchFab) { return;//from w w w.j ava2 s . c om } mShowActionFab = true; if (animation) { long delay; if (View.INVISIBLE == mSearchFab.getVisibility()) { delay = 0L; } else { delay = ANIMATE_TIME; mSearchFab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mSearchFabAnimatorListener) .setDuration(ANIMATE_TIME).setStartDelay(0L) .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start(); } View fab = mFabLayout.getPrimaryFab(); fab.setVisibility(View.VISIBLE); fab.setRotation(-45.0f); fab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null).setDuration(ANIMATE_TIME) .setStartDelay(delay).setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start(); } else { mFabLayout.setExpanded(false, false); View fab = mFabLayout.getPrimaryFab(); fab.setVisibility(View.VISIBLE); fab.setScaleX(1.0f); fab.setScaleY(1.0f); mSearchFab.setVisibility(View.INVISIBLE); mSearchFab.setScaleX(0.0f); mSearchFab.setScaleY(0.0f); } }
From source file:com.arlib.floatingsearchview.util.view.MenuView.java
/** * Hides all the menu items flagged with "ifRoom" * * @param withAnim/*from w ww . j a v a 2 s . c o m*/ */ public void hideIfRoomItems(boolean withAnim) { if (mMenu == -1) return; mActionShowAlwaysItems.clear(); cancelChildAnimListAndClear(); List<MenuItemImpl> showAlwaysActionItems = filter(mMenuItems, new MenuItemImplPredicate() { @Override public boolean apply(MenuItemImpl menuItem) { return menuItem.requiresActionButton(); } }); int actionItemIndex; for (actionItemIndex = 0; actionItemIndex < mActionItems.size() && actionItemIndex < showAlwaysActionItems.size(); actionItemIndex++) { final MenuItemImpl actionItem = showAlwaysActionItems.get(actionItemIndex); if (mActionItems.get(actionItemIndex).getItemId() != showAlwaysActionItems.get(actionItemIndex) .getItemId()) { ImageView action = (ImageView) getChildAt(actionItemIndex); action.setImageDrawable(Util.setIconColor(actionItem.getIcon(), mActionIconColor)); action.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mMenuCallback != null) mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem); } }); } mActionShowAlwaysItems.add(actionItem); } final int diff = mActionItems.size() - actionItemIndex + (mHasOverflow ? 1 : 0); anims = new ArrayList<>(); for (int i = 0; i < actionItemIndex; i++) { final View currentChild = getChildAt(i); final float destTransX = ACTION_DIMENSION_PX * diff - (mHasOverflow ? Util.dpToPx(8) : 0); anims.add(ViewPropertyObjectAnimator.animate(currentChild) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .setInterpolator(new AccelerateInterpolator()).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentChild.setTranslationX(destTransX); } }).translationXBy(destTransX).get()); } for (int i = actionItemIndex; i < diff + actionItemIndex; i++) { final View currentView = getChildAt(i); currentView.setClickable(false); if (i != getChildCount() - 1) anims.add(ViewPropertyObjectAnimator.animate(currentView) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setTranslationX(ACTION_DIMENSION_PX); } }).translationXBy(ACTION_DIMENSION_PX).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleX(0.5f); } }).scaleX(.5f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleY(0.5f); } }).scaleY(.5f).get()); anims.add(ViewPropertyObjectAnimator.animate(getChildAt(i)) .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0) .addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setAlpha(0.0f); } }).alpha(0.0f).get()); } final int actinItemsCount = actionItemIndex; if (!anims.isEmpty()) { AnimatorSet animSet = new AnimatorSet(); if (!withAnim) animSet.setDuration(0); animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()])); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mOnVisibleWidthChanged != null) mOnVisibleWidthChanged.onVisibleWidthChanged(((int) ACTION_DIMENSION_PX * actinItemsCount)); } }); animSet.start(); } }
From source file:me.lizheng.deckview.helpers.DeckChildViewTransform.java
/** * Applies this transform to a view./* w ww . j a v a 2 s. c o m*/ */ public void applyToTaskView(View v, int duration, Interpolator interp, /*boolean allowLayers,*/ boolean allowShadows/*, ValueAnimator.AnimatorUpdateListener updateCallback*/) { // Check to see if any properties have changed, and update the task view if (duration > 0) { ViewPropertyAnimator anim = v.animate(); // boolean requiresLayers = false; // Animate to the final state if (hasTranslationYChangedFrom(v.getTranslationY())) { anim.translationY(translationY); } // if (allowShadows && hasTranslationZChangedFrom(v.getTranslationZ())) { // anim.translationZ(translationZ); // } if (hasScaleChangedFrom(v.getScaleX())) { anim.scaleX(scale).scaleY(scale); // requiresLayers = true; } if (hasAlphaChangedFrom(v.getAlpha())) { // Use layers if we animate alpha anim.alpha(alpha); // requiresLayers = true; } // if (requiresLayers && allowLayers) { // anim.withLayer(); // } // if (updateCallback != null) { // anim.setUpdateListener(updateCallback); // } else { // anim.setUpdateListener(null); // } anim.setStartDelay(startDelay).setDuration(duration).setInterpolator(interp).start(); } else { // Set the changed properties if (hasTranslationYChangedFrom(v.getTranslationY())) { v.setTranslationY(translationY); } if (allowShadows && hasTranslationZChangedFrom(ViewCompat.getTranslationZ(v))) { ViewCompat.setTranslationZ(v, translationZ); } if (hasScaleChangedFrom(v.getScaleX())) { v.setScaleX(scale); v.setScaleY(scale); } if (hasAlphaChangedFrom(v.getAlpha())) { v.setAlpha(alpha); } } }
From source file:com.oguzbabaoglu.cardpager.CardPager.java
/** * Transforms the top and bottom pages with changing scroll. * If top page is moving to the right side (virtualPos > 0) * we need to counteract the scroll by twice as much. * * @param view child view//from w w w . ja v a 2s .co m * @param position position with offset */ protected void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position < -1) { // This page is off-screen view.setAlpha(0); } else if (position <= 0) { view.setAlpha(1); // Counteract the default slide transition if (virtualPos > 0) { view.setTranslationX(pageWidth * -position * 2); } else { view.setTranslationX(0); } // Scale the page down (between MIN_SCALE and 1) float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)); view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); } else if (position <= 1) { // Fade the page out. view.setAlpha(1 - position); // Counteract the default slide transition view.setTranslationX(pageWidth * -position); // Scale the page down (between MIN_SCALE and 1) float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)); view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); } else { // This page is off-screen view.setAlpha(0); } }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
/** * Updates the visibility of status clock (appears above on top of the screen). *///from ww w . java 2s . c om private void updateStatusClockVisibility(boolean visibleNow) { if (mStatusClockTextView == null) { return; } View view = mStatusClockTextView; boolean visible = view.getVisibility() == View.VISIBLE; if (visible == visibleNow) return; if (isAnimatable()) { final float[] values; if (visibleNow) { values = new float[] { 0.0f, 1.0f, 0.8f, 1.0f, 0.8f, 1.0f, }; view.setVisibility(View.VISIBLE); view.animate().setListener(null); } else { values = new float[] { 1.0f, 0.0f, 1.0f, 0.8f, 1.0f, 0.8f, }; view.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mStatusClockTextView.setVisibility(View.GONE); } }); } view.setAlpha(values[0]); view.setScaleX(values[2]); view.setScaleY(values[4]); view.animate().alpha(values[1]).scaleX(values[3]).scaleY(values[5]); } else { ViewUtils.setVisible(view, visibleNow); } }
From source file:com.king.view.superslidingpanelayout.SuperSlidingPaneLayout.java
private void dispatchOnPanelMode(View panel, float slideOffset) { if (mMenuPanel == null) { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child != panel) { mMenuPanel = child;//from ww w. j a v a2 s . c om break; } } } final float scale = 1 - 0.2f * slideOffset; final float scaleLeft = 1 - 0.2f * (1 - slideOffset); switch (mMode) { case TRANSLATION: mMenuPanel.setTranslationX((slideOffset - 1) * mMenuPanel.getWidth()); panel.setScaleX(1); panel.setScaleY(1); break; case SCALE_MENU: mMenuPanel.setPivotX(-0.2f * mMenuPanel.getWidth()); mMenuPanel.setPivotY(mMenuPanel.getHeight() / 2.0f); mMenuPanel.setScaleX(scaleLeft); mMenuPanel.setScaleY(scaleLeft); panel.setScaleX(1); panel.setScaleY(1); break; case SCALE_PANEL: panel.setPivotX(0); panel.setPivotY(panel.getHeight() / 2.0f); panel.setScaleX(scale); panel.setScaleY(scale); break; case SCALE_BOTH: mMenuPanel.setPivotX(-0.2f * mMenuPanel.getWidth()); mMenuPanel.setPivotY(mMenuPanel.getHeight() / 2.0f); mMenuPanel.setScaleX(scaleLeft); mMenuPanel.setScaleY(scaleLeft); panel.setPivotX(0); panel.setPivotY(panel.getHeight() / 2.0f); panel.setScaleX(scale); panel.setScaleY(scale); break; case TRANSLATION_SCALE: mMenuPanel.setTranslationX((slideOffset - 1) * mMenuPanel.getWidth() / 2.0f); mMenuPanel.setPivotX(-0.2f * mMenuPanel.getWidth()); mMenuPanel.setPivotY(mMenuPanel.getHeight() / 2.0f); mMenuPanel.setScaleX(scaleLeft); mMenuPanel.setScaleY(scaleLeft); panel.setPivotX(0); panel.setPivotY(panel.getHeight() / 2.0f); panel.setScaleX(scale); panel.setScaleY(scale); break; case DEFAULT: default: panel.setPivotX(0); panel.setPivotY(0); panel.setScaleX(1); panel.setScaleY(1); break; } }
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
private void selectSearchFab(boolean animation) { if (null == mFabLayout || null == mSearchFab) { return;/*from ww w .j av a 2s . c o m*/ } mShowActionFab = false; if (animation) { View fab = mFabLayout.getPrimaryFab(); long delay; if (View.INVISIBLE == fab.getVisibility()) { delay = 0L; } else { delay = ANIMATE_TIME; fab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mActionFabAnimatorListener) .setDuration(ANIMATE_TIME).setStartDelay(0L) .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start(); } mSearchFab.setVisibility(View.VISIBLE); mSearchFab.setRotation(-45.0f); mSearchFab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null) .setDuration(ANIMATE_TIME).setStartDelay(delay) .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start(); } else { mFabLayout.setExpanded(false, false); View fab = mFabLayout.getPrimaryFab(); fab.setVisibility(View.INVISIBLE); fab.setScaleX(0.0f); fab.setScaleY(0.0f); mSearchFab.setVisibility(View.VISIBLE); mSearchFab.setScaleX(1.0f); mSearchFab.setScaleY(1.0f); } }