Java Code Examples for com.nineoldandroids.view.ViewHelper.setTranslationY()

The following are Jave code examples for showing how to use setTranslationY() of the com.nineoldandroids.view.ViewHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: JewelryUI   File: JazzyViewPager.java   View Source Code Vote up 6 votes
private void animateRotate(View left, View right, float positionOffset, boolean up) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (up ? 1 : -1) * (ROT_MAX * positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, up ? 0 : left.getMeasuredHeight());
			ViewHelper.setTranslationY(left, mTrans);
			ViewHelper.setRotation(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = (up ? 1 : -1) * (-ROT_MAX + ROT_MAX*positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, up ? 0 : right.getMeasuredHeight());
			ViewHelper.setTranslationY(right, mTrans);
			ViewHelper.setRotation(right, mRot);
		}
	}
}
 
Example 2
Project: JewelryUI   File: ViewAnimationUtils.java   View Source Code Vote up 6 votes
/**
 * Lifting view
 *
 * @param view         The animation target
 * @param baseRotation initial Rotation X in 3D space
 * @param fromY        initial Y position of view
 * @param duration     aniamtion duration
 * @param startDelay   start delay before animation begin
 */
@Deprecated
public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay) {
    ViewHelper.setRotationX(view, baseRotation);
    ViewHelper.setTranslationY(view, fromY);

    ViewPropertyAnimator
            .animate(view)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(duration)
            .setStartDelay(startDelay)
            .rotationX(0)
            .translationY(0)
            .start();

}
 
Example 3
Project: JewelryUI   File: ViewAnimationUtils.java   View Source Code Vote up 6 votes
/**
 * Lifting view
 *
 * @param view         The animation target
 * @param baseRotation initial Rotation X in 3D space
 * @param duration     aniamtion duration
 * @param startDelay   start delay before animation begin
 */
@Deprecated
public static void liftingFromBottom(View view, float baseRotation, int duration, int startDelay) {
    ViewHelper.setRotationX(view, baseRotation);
    ViewHelper.setTranslationY(view, view.getHeight() / 3);

    ViewPropertyAnimator
            .animate(view)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(duration)
            .setStartDelay(startDelay)
            .rotationX(0)
            .translationY(0)
            .start();

}
 
Example 4
Project: JazzyViewPager   File: JazzyViewPager.java   View Source Code Vote up 6 votes
private void animateRotate(View left, View right, float positionOffset, boolean up) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mRot = (up ? 1 : -1) * (ROT_MAX * positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(left, up ? 0 : left.getMeasuredHeight());
			ViewHelper.setTranslationY(left, mTrans);
			ViewHelper.setRotation(left, mRot);
		}
		if (right != null) {
			manageLayer(right, true);
			mRot = (up ? 1 : -1) * (-ROT_MAX + ROT_MAX*positionOffset);
			mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
			ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
			ViewHelper.setPivotY(right, up ? 0 : right.getMeasuredHeight());
			ViewHelper.setTranslationY(right, mTrans);
			ViewHelper.setRotation(right, mRot);
		}
	}
}
 
Example 5
Project: ClouldReader   File: Instrument.java   View Source Code Vote up 5 votes
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
        ViewHelper.setTranslationY(view, delta);
    }
}
 
Example 6
Project: GitHub   File: Instrument.java   View Source Code Vote up 5 votes
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
        ViewHelper.setTranslationY(view, delta);
    }
}
 
Example 7
Project: TestChat   File: FloatingActionsMenu.java   View Source Code Vote up 5 votes
private void toggle(final boolean visible, final boolean animate, boolean force) {
        if (mVisible != visible || force) {
                mVisible = visible;
                int height = getHeight();
                if (height == 0 && !force) {
                        ViewTreeObserver vto = getViewTreeObserver();
                        if (vto.isAlive()) {
                                vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                                        @Override
                                        public boolean onPreDraw() {
                                                ViewTreeObserver currentVto = getViewTreeObserver();
                                                if (currentVto.isAlive()) {
                                                        currentVto.removeOnPreDrawListener(this);
                                                }
                                                toggle(visible, animate, true);
                                                return true;
                                        }
                                });
                                return;
                        }
                }
                int translationY = visible ? 0 : height + mAddButton.getMarginBottom();
                if (animate) {
                        ViewPropertyAnimator.animate(this).setInterpolator(mInterpolator)
                                .setDuration(TRANSLATE_DURATION_MILLIS)
                                .translationY(translationY);
                } else {
                        ViewHelper.setTranslationY(this, translationY);
                }

                // On pre-Honeycomb a translated view is still clickable, so we need to disable clicks manually
                if (!hasHoneycombApi()) {
                        setClickable(visible);
                }
        }
}
 
Example 8
Project: Hitalk   File: ImagePagerFragment.java   View Source Code Vote up 5 votes
/**
 * The enter animation scales the picture in from its previous thumbnail
 * size/location, colorizing it in parallel. In parallel, the background of the
 * activity is fading in. When the pictue is in place, the text description
 * drops down.
 */
private void runEnterAnimation() {
  final long duration = ANIM_DURATION;

  // Set starting values for properties we're going to animate. These
  // values scale and position the full size version down to the thumbnail
  // size/location, from which we'll animate it back up
  ViewHelper.setPivotX(mViewPager, 0);
  ViewHelper.setPivotY(mViewPager, 0);
  ViewHelper.setScaleX(mViewPager, (float) thumbnailWidth / mViewPager.getWidth());
  ViewHelper.setScaleY(mViewPager, (float) thumbnailHeight / mViewPager.getHeight());
  ViewHelper.setTranslationX(mViewPager, thumbnailLeft);
  ViewHelper.setTranslationY(mViewPager, thumbnailTop);

  // Animate scale and translation to go from thumbnail to full size
  ViewPropertyAnimator.animate(mViewPager)
      .setDuration(duration)
      .scaleX(1)
      .scaleY(1)
      .translationX(0)
      .translationY(0)
      .setInterpolator(new DecelerateInterpolator());

  // Fade in the black background
  ObjectAnimator bgAnim = ObjectAnimator.ofInt(mViewPager.getBackground(), "alpha", 0, 255);
  bgAnim.setDuration(duration);
  bgAnim.start();

  // Animate a color filter to take the image from grayscale to full color.
  // This happens in parallel with the image scaling and moving into place.
  ObjectAnimator colorizer = ObjectAnimator.ofFloat(ImagePagerFragment.this,
      "saturation", 0, 1);
  colorizer.setDuration(duration);
  colorizer.start();

}
 
Example 9
Project: Hitalk   File: FloatingActionButton.java   View Source Code Vote up 5 votes
private void toggle(final boolean visible, final boolean animate, boolean force) {
    if (mVisible != visible || force) {
        mVisible = visible;
        int height = getHeight();
        if (height == 0 && !force) {
            ViewTreeObserver vto = getViewTreeObserver();
            if (vto.isAlive()) {
                vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                    @Override
                    public boolean onPreDraw() {
                        ViewTreeObserver currentVto = getViewTreeObserver();
                        if (currentVto.isAlive()) {
                            currentVto.removeOnPreDrawListener(this);
                        }
                        toggle(visible, animate, true);
                        return true;
                    }
                });
                return;
            }
        }
        int translationY = visible ? 0 : height + getMarginBottom();
        if (animate) {
            ViewPropertyAnimator.animate(this).setInterpolator(mInterpolator)
                    .setDuration(TRANSLATE_DURATION_MILLIS)
                    .translationY(translationY);
        } else {
            ViewHelper.setTranslationY(this, translationY);
        }

        // On pre-Honeycomb a translated view is still clickable, so we need to disable clicks manually
        if (!hasHoneycombApi()) {
            setClickable(visible);
        }
    }
}
 
Example 10
Project: JewelryUI   File: ViewAnimationUtils.java   View Source Code Vote up 5 votes
/**
 * Lifting view
 *
 * @param view         The animation target
 * @param baseRotation initial Rotation X in 3D space
 * @param duration     aniamtion duration
 */
@Deprecated
public static void liftingFromBottom(View view, float baseRotation, int duration) {
    ViewHelper.setRotationX(view, baseRotation);
    ViewHelper.setTranslationY(view, view.getHeight() / 3);

    ViewPropertyAnimator
            .animate(view)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(duration)
            .rotationX(0)
            .translationY(0)
            .start();

}
 
Example 11
Project: NeteaseCloudMusic   File: ScanMusicActivity.java   View Source Code Vote up 5 votes
public void finishAnimations() {
    scanAnimation.cancel();
    searchAnimation.cancel();
    ivScanEffect.clearAnimation();
    ivScanEffect.setVisibility(View.GONE);
    ivSearch.clearAnimation();
    ViewHelper.setTranslationX(ivSearch, 0f);
    ViewHelper.setTranslationY(ivSearch, 0f);

}
 
Example 12
Project: GongXianSheng   File: BaseViewAnimator.java   View Source Code Vote up 5 votes
/**
 * reset the view to default status
 *
 * @param target
 */
public void reset(View target) {
	ViewHelper.setAlpha(target, 1);
	ViewHelper.setScaleX(target, 1);
	ViewHelper.setScaleY(target, 1);
	ViewHelper.setTranslationX(target, 0);
	ViewHelper.setTranslationY(target, 0);
	ViewHelper.setRotation(target, 0);
	ViewHelper.setRotationY(target, 0);
	ViewHelper.setRotationX(target, 0);
	ViewHelper.setPivotX(target, target.getMeasuredWidth() / 2.0f);
	ViewHelper.setPivotY(target, target.getMeasuredHeight() / 2.0f);
}
 
Example 13
Project: MyAnimeViewer   File: BaseItemAnimator.java   View Source Code Vote up 5 votes
public static void clear(View v) {
    ViewHelper.setAlpha(v, 1);
    ViewHelper.setScaleY(v, 1);
    ViewHelper.setScaleX(v, 1);
    ViewHelper.setTranslationY(v, 0);
    ViewHelper.setTranslationX(v, 0);
    ViewHelper.setRotation(v, 0);
    ViewHelper.setRotationY(v, 0);
    ViewHelper.setRotationX(v, 0);
    // @TODO https://code.google.com/p/android/issues/detail?id=80863
    //        ViewHelper.setPivotY(v, v.getMeasuredHeight() / 2);
    v.setPivotY(v.getMeasuredHeight() / 2);
    ViewHelper.setPivotX(v, v.getMeasuredWidth() / 2);
    ViewPropertyAnimator.animate(v).setInterpolator(null);
}
 
Example 14
Project: PhotoPicker-master   File: ImagePagerFragment.java   View Source Code Vote up 5 votes
/**
 * The enter animation scales the picture in from its previous thumbnail
 * size/location, colorizing it in parallel. In parallel, the background of the
 * activity is fading in. When the pictue is in place, the text description
 * drops down.
 */
private void runEnterAnimation() {
  final long duration = ANIM_DURATION;

  // Set starting values for properties we're going to animate. These
  // values scale and position the full size version down to the thumbnail
  // size/location, from which we'll animate it back up
  ViewHelper.setPivotX(mViewPager, 0);
  ViewHelper.setPivotY(mViewPager, 0);
  ViewHelper.setScaleX(mViewPager, (float) thumbnailWidth / mViewPager.getWidth());
  ViewHelper.setScaleY(mViewPager, (float) thumbnailHeight / mViewPager.getHeight());
  ViewHelper.setTranslationX(mViewPager, thumbnailLeft);
  ViewHelper.setTranslationY(mViewPager, thumbnailTop);

  // Animate scale and translation to go from thumbnail to full size
  ViewPropertyAnimator.animate(mViewPager)
      .setDuration(duration)
      .scaleX(1)
      .scaleY(1)
      .translationX(0)
      .translationY(0)
      .setInterpolator(new DecelerateInterpolator());

  // Fade in the black background
  ObjectAnimator bgAnim = ObjectAnimator.ofInt(mViewPager.getBackground(), "alpha", 0, 255);
  bgAnim.setDuration(duration);
  bgAnim.start();

  // Animate a color filter to take the image from grayscale to full color.
  // This happens in parallel with the image scaling and moving into place.
  ObjectAnimator colorizer = ObjectAnimator.ofFloat(ImagePagerFragment.this,
      "saturation", 0, 1);
  colorizer.setDuration(duration);
  colorizer.start();

}
 
Example 15
Project: Shared-Route   File: BaseAnimatorSet.java   View Source Code Vote up 5 votes
public static void reset(View view) {
	ViewHelper.setAlpha(view, 1);
	ViewHelper.setScaleX(view, 1);
	ViewHelper.setScaleY(view, 1);
	ViewHelper.setTranslationX(view, 0);
	ViewHelper.setTranslationY(view, 0);
	ViewHelper.setRotation(view, 0);
	ViewHelper.setRotationY(view, 0);
	ViewHelper.setRotationX(view, 0);
}
 
Example 16
Project: Nearby   File: MedicineDetailActivity.java   View Source Code Vote up 4 votes
@Override
    public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
        draggerView.setSlideEnabled(scrollY <= 0);
        // Translate overlay and image
        float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize;
        int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight();
        ViewHelper.setTranslationY(mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
        ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));

        // Change alpha of overlay
//        ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

        // Scale title text
        float scale = 1 + ScrollUtils.getFloat((flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
        ViewHelper.setPivotX(mTitleView, 0);
        ViewHelper.setPivotY(mTitleView, 0);
        ViewHelper.setScaleX(mTitleView, scale);
        ViewHelper.setScaleY(mTitleView, scale);

        // Translate title text
        int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale);
        int titleTranslationY = maxTitleTranslationY - scrollY;
        ViewHelper.setTranslationY(mTitleView, titleTranslationY);

        // Translate FAB
        int maxFabTranslationY = mFlexibleSpaceImageHeight - 0 / 2;
        float fabTranslationY = ScrollUtils.getFloat(
                -scrollY + mFlexibleSpaceImageHeight - 0 / 2,
                mActionBarSize - 0 / 2,
                maxFabTranslationY);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            // On pre-honeycomb, ViewHelper.setTranslationX/Y does not set margin,
            // which causes FAB's OnClickListener not working.
//            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFab.getLayoutParams();
//            lp.leftMargin = mOverlayView.getWidth() - mFabMargin - mFab.getWidth();
//            lp.topMargin = (int) fabTranslationY;
//            mFab.requestLayout();
        } else {
//            ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth());
//            ViewHelper.setTranslationY(mFab, fabTranslationY);
        }

        // Show/hide FAB
        if (fabTranslationY < mFlexibleSpaceShowFabOffset) {
            hideFab();
        } else {
            showFab();
        }
    }
 
Example 17
Project: Nearby   File: PatientDetailActivity.java   View Source Code Vote up 4 votes
@Override
    public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
        draggerView.setSlideEnabled(scrollY <= 0);
        // Translate overlay and image
        float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize;
        int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight();
        ViewHelper.setTranslationY(mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
        ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));

        // Change alpha of overlay
//        ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

        // Scale title text
        float scale = 1 + ScrollUtils.getFloat((flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
        ViewHelper.setPivotX(mTitleView, 0);
        ViewHelper.setPivotY(mTitleView, 0);
        ViewHelper.setScaleX(mTitleView, scale);
        ViewHelper.setScaleY(mTitleView, scale);

        // Translate title text
        int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale);
        int titleTranslationY = maxTitleTranslationY - scrollY;
        ViewHelper.setTranslationY(mTitleView, titleTranslationY);

        // Translate FAB
        int maxFabTranslationY = mFlexibleSpaceImageHeight - 0 / 2;
        float fabTranslationY = ScrollUtils.getFloat(
                -scrollY + mFlexibleSpaceImageHeight - 0 / 2,
                mActionBarSize - 0 / 2,
                maxFabTranslationY);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            // On pre-honeycomb, ViewHelper.setTranslationX/Y does not set margin,
            // which causes FAB's OnClickListener not working.
//            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFab.getLayoutParams();
//            lp.leftMargin = mOverlayView.getWidth() - mFabMargin - mFab.getWidth();
//            lp.topMargin = (int) fabTranslationY;
//            mFab.requestLayout();
        } else {
//            ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth());
//            ViewHelper.setTranslationY(mFab, fabTranslationY);
        }

        // Show/hide FAB
        if (fabTranslationY < mFlexibleSpaceShowFabOffset) {
            hideFab();
        } else {
            showFab();
        }
    }
 
Example 18
Project: Nearby   File: LogDetailInfoActivity.java   View Source Code Vote up 4 votes
@Override
    public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
        draggerView.setSlideEnabled(scrollY <= 0);
        // Translate overlay and image
        float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize;
        int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight();
        ViewHelper.setTranslationY(mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
        ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));

        // Change alpha of overlay
//        ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

        // Scale title text
        float scale = 1 + ScrollUtils.getFloat((flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
        ViewHelper.setPivotX(mTitleView, 0);
        ViewHelper.setPivotY(mTitleView, 0);
        ViewHelper.setScaleX(mTitleView, scale);
        ViewHelper.setScaleY(mTitleView, scale);

        // Translate title text
        int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale);
        int titleTranslationY = maxTitleTranslationY - scrollY;
        ViewHelper.setTranslationY(mTitleView, titleTranslationY);

        // Translate FAB
        int maxFabTranslationY = mFlexibleSpaceImageHeight - 0 / 2;
        float fabTranslationY = ScrollUtils.getFloat(
                -scrollY + mFlexibleSpaceImageHeight - 0 / 2,
                mActionBarSize - 0 / 2,
                maxFabTranslationY);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            // On pre-honeycomb, ViewHelper.setTranslationX/Y does not set margin,
            // which causes FAB's OnClickListener not working.
//            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFab.getLayoutParams();
//            lp.leftMargin = mOverlayView.getWidth() - mFabMargin - mFab.getWidth();
//            lp.topMargin = (int) fabTranslationY;
//            mFab.requestLayout();
        } else {
//            ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth());
//            ViewHelper.setTranslationY(mFab, fabTranslationY);
        }

        // Show/hide FAB
        if (fabTranslationY < mFlexibleSpaceShowFabOffset) {
            hideFab();
        } else {
            showFab();
        }
    }
 
Example 19
Project: Nearby   File: EmployeeDetailActivity.java   View Source Code Vote up 4 votes
@Override
    public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
        draggerView.setSlideEnabled(scrollY <= 0);
        // Translate overlay and image
        float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize;
        int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight();
        ViewHelper.setTranslationY(mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
        ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));

        // Change alpha of overlay
//        ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

        // Scale title text
        float scale = 1 + ScrollUtils.getFloat((flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
        ViewHelper.setPivotX(mTitleView, 0);
        ViewHelper.setPivotY(mTitleView, 0);
        ViewHelper.setScaleX(mTitleView, scale);
        ViewHelper.setScaleY(mTitleView, scale);

        // Translate title text
        int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale);
        int titleTranslationY = maxTitleTranslationY - scrollY;
        ViewHelper.setTranslationY(mTitleView, titleTranslationY);

        // Translate FAB
        int maxFabTranslationY = mFlexibleSpaceImageHeight - 0 / 2;
        float fabTranslationY = ScrollUtils.getFloat(
                -scrollY + mFlexibleSpaceImageHeight - 0 / 2,
                mActionBarSize - 0 / 2,
                maxFabTranslationY);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            // On pre-honeycomb, ViewHelper.setTranslationX/Y does not set margin,
            // which causes FAB's OnClickListener not working.
//            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFab.getLayoutParams();
//            lp.leftMargin = mOverlayView.getWidth() - mFabMargin - mFab.getWidth();
//            lp.topMargin = (int) fabTranslationY;
//            mFab.requestLayout();
        } else {
//            ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth());
//            ViewHelper.setTranslationY(mFab, fabTranslationY);
        }

        // Show/hide FAB
        if (fabTranslationY < mFlexibleSpaceShowFabOffset) {
            hideFab();
        } else {
            showFab();
        }
    }
 
Example 20
Project: Sega   File: BaseTransformer.java   View Source Code Vote up 4 votes
/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called.
 *
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
    final float width = view.getWidth();

    ViewHelper.setRotationX(view,0);
    ViewHelper.setRotationY(view,0);
    ViewHelper.setRotation(view,0);
    ViewHelper.setScaleX(view,1);
    ViewHelper.setScaleY(view,1);
    ViewHelper.setPivotX(view,0);
    ViewHelper.setPivotY(view,0);
    ViewHelper.setTranslationY(view,0);
    ViewHelper.setTranslationX(view,isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        ViewHelper.setAlpha(view,position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        ViewHelper.setAlpha(view,1f);
    }
    if(mCustomAnimationInterface != null){
        if(!h.containsKey(view) || h.get(view).size() == 1){
            if(position > -1 && position < 1){
                if(h.get(view) == null){
                    h.put(view,new ArrayList<Float>());
                }
                h.get(view).add(position);
                if(h.get(view).size() == 2){
                    float zero = h.get(view).get(0);
                    float cha = h.get(view).get(1) - h.get(view).get(0);
                    if(zero > 0){
                        if(cha > -1 && cha < 0){
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }else{
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }
                    }else{
                        if(cha > -1 && cha < 0){
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }else{
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }
                    }
                }
            }
        }
    }
}