Java Code Examples for com.nineoldandroids.view.ViewHelper#setTranslationY()
The following examples show how to use
com.nineoldandroids.view.ViewHelper#setTranslationY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewAnimationUtils.java From fab-toolbar with MIT License | 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 2
Source File: FlexibleSpaceToolbarScrollViewActivity.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private void updateFlexibleSpaceText(final int scrollY) { ViewHelper.setTranslationY(mFlexibleSpaceView, -scrollY); int adjustedScrollY = scrollY; if (scrollY < 0) { adjustedScrollY = 0; } else if (mFlexibleSpaceHeight < scrollY) { adjustedScrollY = mFlexibleSpaceHeight; } float maxScale = (float) (mFlexibleSpaceHeight - mToolbarView.getHeight()) / mToolbarView.getHeight(); float scale = maxScale * ((float) mFlexibleSpaceHeight - adjustedScrollY) / mFlexibleSpaceHeight; ViewHelper.setPivotX(mTitleView, 0); ViewHelper.setPivotY(mTitleView, 0); ViewHelper.setScaleX(mTitleView, 1 + scale); ViewHelper.setScaleY(mTitleView, 1 + scale); ViewHelper.setTranslationY(mTitleView, ViewHelper.getTranslationY(mFlexibleSpaceView) + mFlexibleSpaceView.getHeight() - mTitleView.getHeight() * (1 + scale)); int maxTitleTranslationY = mToolbarView.getHeight() + mFlexibleSpaceHeight - (int) (mTitleView.getHeight() * (1 + scale)); int titleTranslationY = (int) (maxTitleTranslationY * ((float) mFlexibleSpaceHeight - adjustedScrollY) / mFlexibleSpaceHeight); ViewHelper.setTranslationY(mTitleView, titleTranslationY); }
Example 3
Source File: ViewAnimationUtils.java From RecyclerView-Animation-Demo with Apache License 2.0 | 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 4
Source File: LockHeaderView.java From PullRefreshView with Apache License 2.0 | 6 votes |
@Override public boolean onScroll(float y) { boolean intercept = super.onScroll(y); ViewHelper.setTranslationY(loadBox, 0.97f * y - loadBox.getHeight()); if (!isLockState()) { ViewHelper.setRotation(progress, y * y * 48 / 31250); } path.reset();// 重置path if (y == 0) { invalidate(); return intercept; } // 贝赛尔曲线的起始点 path.moveTo(0, 0); // 设置贝赛尔曲线的操作点以及终止点 path.quadTo(width / 2, 1.94f * y, width, 0); invalidate(); return intercept; }
Example 5
Source File: FlexibleSpaceWithImageRecyclerViewFragment.java From Android-ObservableScrollView with Apache License 2.0 | 6 votes |
@Override protected void updateFlexibleSpace(int scrollY, View view) { int flexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height); View recyclerViewBackground = view.findViewById(R.id.list_background); // Translate list background ViewHelper.setTranslationY(recyclerViewBackground, Math.max(0, -scrollY + flexibleSpaceImageHeight)); // Also pass this event to parent Activity FlexibleSpaceWithImageWithViewPagerTabActivity parentActivity = (FlexibleSpaceWithImageWithViewPagerTabActivity) getActivity(); if (parentActivity != null) { parentActivity.onScrollChanged(scrollY, (ObservableRecyclerView) view.findViewById(R.id.scroll)); } }
Example 6
Source File: LockFooterView.java From PullRefreshView with Apache License 2.0 | 6 votes |
@Override public boolean onScroll(float y) { boolean intercept = super.onScroll(y); ViewHelper.setTranslationY(loadBox, 400 + 0.97f * y); if (!isLockState()) { ViewHelper.setRotation(progress, y * y * 48 / 31250); } path.reset();// 重置path if (y == 0) { invalidate(); return intercept; } // 贝赛尔曲线的起始点 path.moveTo(0, 400); // 设置贝赛尔曲线的操作点以及终止点 path.quadTo(width / 2, 400 + 1.94f * y, width, 400); invalidate(); return intercept; }
Example 7
Source File: AboutActivity.java From sharelock-android with MIT License | 6 votes |
protected void updateViews(int scrollY, boolean animated) { // If it's ListView, onScrollChanged is called before ListView is laid out (onGlobalLayout). // This causes weird animation when onRestoreInstanceState occurred, // so we check if it's laid out already. if (!mReady) { return; } // Translate header ViewHelper.setTranslationY(mHeader, getHeaderTranslationY(scrollY)); // Show/hide gap final int headerHeight = mHeaderBar.getHeight(); boolean scrollUp = mPrevScrollY < scrollY; if (scrollUp) { if (mFlexibleSpaceImageHeight - headerHeight - mActionBarSize <= scrollY) { changeHeaderBackgroundHeightAnimated(false, animated); } } else { if (scrollY <= mFlexibleSpaceImageHeight - headerHeight - mActionBarSize) { changeHeaderBackgroundHeightAnimated(true, animated); } } mPrevScrollY = scrollY; }
Example 8
Source File: JellyViewPager.java From Conquer with Apache License 2.0 | 5 votes |
@Override public void onPageSelected(int position) { if (pageChangeListener != null) { pageChangeListener.onPageSelected(position); } if (currentView != null) { ViewHelper.setTranslationY(currentView, 0); ViewHelper.setRotation(currentView, 0); } mScaleSpring.setCurrentValue(MIN_SCALE); mScaleSpring.setEndValue(MAX_SCALE); }
Example 9
Source File: ViewPagerTabListViewActivity.java From Android-ObservableScrollView with Apache License 2.0 | 5 votes |
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { if (dragging) { int toolbarHeight = mToolbarView.getHeight(); float currentHeaderTranslationY = ViewHelper.getTranslationY(mHeaderView); if (firstScroll) { if (-toolbarHeight < currentHeaderTranslationY) { mBaseTranslationY = scrollY; } } float headerTranslationY = ScrollUtils.getFloat(-(scrollY - mBaseTranslationY), -toolbarHeight, 0); ViewPropertyAnimator.animate(mHeaderView).cancel(); ViewHelper.setTranslationY(mHeaderView, headerTranslationY); } }
Example 10
Source File: PropertyAction.java From android-player with Apache License 2.0 | 5 votes |
@Override public void init(View view) { setToTranslationX(ViewHelper.getTranslationX(view)); ViewHelper.setTranslationX(view, getTranslationX()); setToTranslationY(ViewHelper.getTranslationY(view)); ViewHelper.setTranslationY(view, getTranslationY()); setToScaleX(ViewHelper.getScaleX(view)); ViewHelper.setScaleX(view, getScaleX()); setToScaleY(ViewHelper.getScaleY(view)); ViewHelper.setScaleY(view, getScaleY()); setToAlpha(ViewHelper.getAlpha(view)); ViewHelper.setAlpha(view, getAlpha()); setToRotation(ViewHelper.getRotation(view)); ViewHelper.setRotation(view, getRotation()); }
Example 11
Source File: Instrument.java From LLApp with Apache License 2.0 | 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 12
Source File: ViewAnimationUtils.java From ExpressHelper with GNU General Public License v3.0 | 5 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 */ 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 13
Source File: BaseViewAnimator.java From UltimateAndroid with Apache License 2.0 | 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 14
Source File: InitdFragment.java From KA27 with Apache License 2.0 | 5 votes |
@Override public void resetTranslations() { super.resetTranslations(); ViewHelper.setTranslationY(addButtonBg, 0); if (fabHideScrollListener != null) { fabHideScrollListener.hide = false; fabHideScrollListener.reset = true; } }
Example 15
Source File: ViewAnimationUtils.java From ExpressHelper with GNU General Public License v3.0 | 5 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 */ 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 16
Source File: FillGapBaseActivity.java From Android-ObservableScrollView with Apache License 2.0 | 5 votes |
protected void updateViews(int scrollY, boolean animated) { // If it's ListView, onScrollChanged is called before ListView is laid out (onGlobalLayout). // This causes weird animation when onRestoreInstanceState occurred, // so we check if it's laid out already. if (!mReady) { return; } // Translate image ViewHelper.setTranslationY(mImage, -scrollY / 2); // Translate header ViewHelper.setTranslationY(mHeader, getHeaderTranslationY(scrollY)); // Show/hide gap final int headerHeight = mHeaderBar.getHeight(); boolean scrollUp = mPrevScrollY < scrollY; if (scrollUp) { if (mFlexibleSpaceImageHeight - headerHeight - mActionBarSize <= scrollY) { changeHeaderBackgroundHeightAnimated(false, animated); } } else { if (scrollY <= mFlexibleSpaceImageHeight - headerHeight - mActionBarSize) { changeHeaderBackgroundHeightAnimated(true, animated); } } mPrevScrollY = scrollY; }
Example 17
Source File: BaseTransformer.java From AndroidImageSlider with MIT License | 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) == false || 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); } } } } } } }
Example 18
Source File: ParentFragment.java From kernel_adiutor with Apache License 2.0 | 4 votes |
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); scrollDistance += dy; logoViewContainer += dy; float logoViewTranslation = logoViewContainer / 2; int logoContainerHeight = parentFragment.logoContainer.getHeight(); if (logoViewTranslation > logoContainerHeight) logoViewTranslation = logoContainerHeight; else if (logoViewTranslation < 0) logoViewTranslation = 0; ViewHelper.setTranslationY(parentFragment.logoContainer, -logoViewTranslation); viewContainerOffset += dy; int viewContainerHeight = parentFragment.viewContainer.getHeight(); if (viewContainerOffset > viewContainerHeight) viewContainerOffset = viewContainerHeight; else if (viewContainerOffset < 0) viewContainerOffset = 0; ViewHelper.setTranslationY(parentFragment.viewContainer, -viewContainerOffset); int toolbarHeight = parentFragment.toolbar.getHeight(); if (viewContainerOffset >= viewContainerHeight - toolbarHeight - parentFragment.mTabs.getHeight() || dy < 0) { toolbarOffset += dy; if (toolbarOffset > toolbarHeight) toolbarOffset = toolbarHeight; else if (toolbarOffset < 0) toolbarOffset = 0; ViewHelper.setTranslationY(parentFragment.toolbar, -toolbarOffset); } if (!isColored && scrollDistance >= viewContainerHeight - toolbarHeight && dy < 0) { parentFragment.toolbar.setBackgroundColor(context.getResources().getColor(R.color.color_primary)); parentFragment.descriptionText.setVisibility(View.VISIBLE); parentFragment.viewContainerBackground.setBackgroundColor(context.getResources() .getColor(R.color.color_primary)); isColored = true; } if (isColored && scrollDistance == 0) { parentFragment.toolbar.setBackgroundColor(Color.TRANSPARENT); parentFragment.viewContainerBackground.startAnimation(parentFragment.animation); isColored = false; } }
Example 19
Source File: FlexibleSpaceWithImageListViewActivity.java From UltimateAndroid with Apache License 2.0 | 4 votes |
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { // Translate overlay and image float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize; int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight(); ViewHelper.setTranslationY(mOverlayView, Math.max(minOverlayTransitionY, Math.min(0, -scrollY))); ViewHelper.setTranslationY(mImageView, Math.max(minOverlayTransitionY, Math.min(0, -scrollY / 2))); // Translate list background ViewHelper.setTranslationY(mListBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight)); // Change alpha of overlay ViewHelper.setAlpha(mOverlayView, Math.max(0, Math.min(1, (float) scrollY / flexibleRange))); // Scale title text float scale = 1 + Math.max(0, Math.min(MAX_TEXT_SCALE_DELTA, (flexibleRange - scrollY) / flexibleRange)); 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; if (TOOLBAR_IS_STICKY) { titleTranslationY = Math.max(0, titleTranslationY); } ViewHelper.setTranslationY(mTitleView, titleTranslationY); // Translate FAB int maxFabTranslationY = mFlexibleSpaceImageHeight - mFab.getHeight() / 2; int fabTranslationY = Math.max(mActionBarSize - mFab.getHeight() / 2, Math.min(maxFabTranslationY, -scrollY + mFlexibleSpaceImageHeight - mFab.getHeight() / 2)); ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth()); ViewHelper.setTranslationY(mFab, fabTranslationY); // Show/hide FAB if (ViewHelper.getTranslationY(mFab) < mFlexibleSpaceShowFabOffset) { hideFab(); } else { showFab(); } if (TOOLBAR_IS_STICKY) { // Change alpha of toolbar background if (-scrollY + mFlexibleSpaceImageHeight <= mActionBarSize) { setBackgroundAlpha(mToolbar, 1, mToolbarColor); } else { setBackgroundAlpha(mToolbar, 0, mToolbarColor); } } else { // Translate Toolbar if (scrollY < mFlexibleSpaceImageHeight) { ViewHelper.setTranslationY(mToolbar, 0); } else { ViewHelper.setTranslationY(mToolbar, -scrollY); } } }
Example 20
Source File: BaseTransformer.java From UltimateAndroid with Apache License 2.0 | 4 votes |
/** * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.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) == false || 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); } } } } } } }