Java Code Examples for com.nineoldandroids.view.ViewHelper#setScaleX()

The following examples show how to use com.nineoldandroids.view.ViewHelper#setScaleX() . 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: SlidingUpBaseActivity.java    From Android-ObservableScrollView with Apache License 2.0 6 votes vote down vote up
private void showFab(boolean animated) {
    if (mFab == null) {
        return;
    }
    if (!mFabIsShown) {
        if (animated) {
            ViewPropertyAnimator.animate(mFab).cancel();
            ViewPropertyAnimator.animate(mFab).scaleX(1).scaleY(1).setDuration(200).start();
        } else {
            ViewHelper.setScaleX(mFab, 1);
            ViewHelper.setScaleY(mFab, 1);
        }
        mFabIsShown = true;
    } else {
        // Ensure that FAB is shown
        ViewHelper.setScaleX(mFab, 1);
        ViewHelper.setScaleY(mFab, 1);
    }
}
 
Example 2
Source File: JazzyViewPager.java    From school_shop with MIT License 6 votes vote down vote up
private void animateAccordion(View left, View right, float positionOffset) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			ViewHelper.setPivotX(left, left.getMeasuredWidth());
			ViewHelper.setPivotY(left, 0);
			ViewHelper.setScaleX(left, 1-positionOffset);
		}
		if (right != null) {
			manageLayer(right, true);
			ViewHelper.setPivotX(right, 0);
			ViewHelper.setPivotY(right, 0);
			ViewHelper.setScaleX(right, positionOffset);
		}
	}
}
 
Example 3
Source File: JazzyViewPager.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
private void animateZoom(View left, View right, float positionOffset,
		boolean in) {
	if (mState != State.IDLE) {
		if (left != null) {
			manageLayer(left, true);
			mScale = in ? ZOOM_MAX + (1 - ZOOM_MAX) * (1 - positionOffset)
					: 1 + ZOOM_MAX - ZOOM_MAX * (1 - positionOffset);
			ViewHelper.setPivotX(left, left.getMeasuredWidth() * 0.5f);
			ViewHelper.setPivotY(left, left.getMeasuredHeight() * 0.5f);
			ViewHelper.setScaleX(left, mScale);
			ViewHelper.setScaleY(left, mScale);
		}
		if (right != null) {
			manageLayer(right, true);
			mScale = in ? ZOOM_MAX + (1 - ZOOM_MAX) * positionOffset : 1
					+ ZOOM_MAX - ZOOM_MAX * positionOffset;
			ViewHelper.setPivotX(right, right.getMeasuredWidth() * 0.5f);
			ViewHelper.setPivotY(right, right.getMeasuredHeight() * 0.5f);
			ViewHelper.setScaleX(right, mScale);
			ViewHelper.setScaleY(right, mScale);
		}
	}
}
 
Example 4
Source File: LoadingView.java    From android-shapeLoadingView with Apache License 2.0 6 votes vote down vote up
private void init(Context context, AttributeSet attrs) {

        setOrientation(VERTICAL);
        mDistance = dip2px(context, 54f);
        LayoutInflater.from(context).inflate(R.layout.load_view, this, true);
        mShapeLoadingView = (ShapeLoadingView) findViewById(R.id.shapeLoadingView);
        mIndicationIm = (ImageView) findViewById(R.id.indication);
        mLoadTextView = (TextView) findViewById(R.id.promptTV);
        ViewHelper.setScaleX(mIndicationIm, 0.2f);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LoadingView);
        String loadText = typedArray.getString(R.styleable.LoadingView_loadingText);
        int textAppearance = typedArray.getResourceId(R.styleable.LoadingView_loadingText, -1);
        mDelay = typedArray.getInteger(R.styleable.LoadingView_delay, 80);
        typedArray.recycle();

        if (textAppearance != -1) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                mLoadTextView.setTextAppearance(textAppearance);
            } else {
                mLoadTextView.setTextAppearance(getContext(), textAppearance);
            }
        }
        setLoadingText(loadText);
    }
 
Example 5
Source File: DepthPageTransformer.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	if (position <= 0f) {
           ViewHelper.setTranslationX(view,0f);
           ViewHelper.setScaleX(view,1f);
           ViewHelper.setScaleY(view,1f);
	} else if (position <= 1f) {
		final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
           ViewHelper.setAlpha(view,1-position);
           ViewHelper.setPivotY(view,0.5f * view.getHeight());
           ViewHelper.setTranslationX(view,view.getWidth() * - position);
           ViewHelper.setScaleX(view,scaleFactor);
           ViewHelper.setScaleY(view,scaleFactor);
	}
}
 
Example 6
Source File: IndicatorBaseAnimator.java    From FlycoPageIndicator with MIT License 5 votes vote down vote up
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 7
Source File: FilmAdapter.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
@Override
protected void bindView(BaseBindingHolder holder, FilmItemBean positionData, ItemFilmBinding binding, int position) {
    if (positionData != null) {
        binding.setSubjectsBean(positionData);
        ViewHelper.setScaleX(binding.llOneItem, 0.8f);
        ViewHelper.setScaleY(binding.llOneItem, 0.8f);
        ViewPropertyAnimator.animate(binding.llOneItem).scaleX(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start();
        ViewPropertyAnimator.animate(binding.llOneItem).scaleY(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start();
    }
}
 
Example 8
Source File: RotateTransformer.java    From Social with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View view, float position) {
	if (position < -1) {
	} else if (position <= 0) {
		ViewHelper.setScaleX(view, 1 + position);
		ViewHelper.setScaleY(view, 1 + position);
		ViewHelper.setRotation(view, 360 * position);
	} else if (position <= 1) {
		ViewHelper.setScaleX(view, 1 - position);
		ViewHelper.setScaleY(view, 1 - position);
		ViewHelper.setRotation(view, 360 * position);
	} else {
	}
}
 
Example 9
Source File: FlexibleSpaceToolbarScrollViewActivity.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
private void updateFlexibleSpaceText(final int scrollY) {
    ViewHelper.setTranslationY(mFlexibleSpaceView, -scrollY);
    int adjustedScrollY = (int) ScrollUtils.getFloat(scrollY, 0, 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);
    int maxTitleTranslationY = mToolbarView.getHeight() + mFlexibleSpaceHeight - (int) (mTitleView.getHeight() * (1 + scale));
    int titleTranslationY = (int) (maxTitleTranslationY * ((float) mFlexibleSpaceHeight - adjustedScrollY) / mFlexibleSpaceHeight);
    ViewHelper.setTranslationY(mTitleView, titleTranslationY);
}
 
Example 10
Source File: ZoomOutSlideTransformer.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	if (position >= -1 || position <= 1) {
		// Modify the default slide transition to shrink the page as well
		final float height = view.getHeight();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = view.getWidth() * (1 - scaleFactor) / 2;

           // Center vertically
           ViewHelper.setPivotY(view,0.5f * height);


		if (position < 0) {
               ViewHelper.setTranslationX(view,horzMargin - vertMargin / 2);
		} else {
               ViewHelper.setTranslationX(view,-horzMargin + vertMargin / 2);
		}

		// Scale the page down (between MIN_SCALE and 1)
		ViewHelper.setScaleX(view,scaleFactor);
           ViewHelper.setScaleY(view,scaleFactor);

		// Fade the page relative to its size.
           ViewHelper.setAlpha(view,MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
	}
}
 
Example 11
Source File: ImagePagerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
/**
 * 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 12
Source File: ForegroundToBackgroundTransformer.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float height = view.getHeight();
	final float width = view.getWidth();
	final float scale = min(position > 0 ? 1f : Math.abs(1f + position), 0.5f);

	ViewHelper.setScaleX(view,scale);
       ViewHelper.setScaleY(view,scale);
       ViewHelper.setPivotX(view,width * 0.5f);
       ViewHelper.setPivotY(view,height * 0.5f);
       ViewHelper.setTranslationX(view,position > 0 ? width * position : -width * position * 0.25f);
}
 
Example 13
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
	float currentActivityScaleX = ViewHelper.getScaleX(viewActivity);
	if (currentActivityScaleX == 1.0f)
		setScaleDirectionByRawX(ev.getRawX());

	switch (ev.getAction()) {
	case MotionEvent.ACTION_DOWN:
		lastActionDownX = ev.getX();
		lastActionDownY = ev.getY();
		isInIgnoredView = isInIgnoredView(ev) && !isOpened();
		pressedState = PRESSED_DOWN;
		break;

	case MotionEvent.ACTION_MOVE:
		if (isInIgnoredView || isInDisableDirection(scaleDirection))
			break;

		if (pressedState != PRESSED_DOWN
				&& pressedState != PRESSED_MOVE_HORIZANTAL)
			break;

		int xOffset = (int) (ev.getX() - lastActionDownX);
		int yOffset = (int) (ev.getY() - lastActionDownY);

		if (pressedState == PRESSED_DOWN) {
			if (yOffset > 50 || yOffset < -50) { // origin = 25
				pressedState = PRESSED_MOVE_VERTICAL;
				break;
			}
			if (xOffset < -50 || xOffset > 50) {
				pressedState = PRESSED_MOVE_HORIZANTAL;
				ev.setAction(MotionEvent.ACTION_CANCEL);
			}
		} else if (pressedState == PRESSED_MOVE_HORIZANTAL) {
			if (currentActivityScaleX < 0.90) // 0.95
				showScrollViewMenu(scrollViewMenu);

			float targetScale = getTargetScale(ev.getRawX());
			ViewHelper.setScaleX(viewActivity, targetScale);
			ViewHelper.setScaleY(viewActivity, targetScale);
			ViewHelper.setScaleX(imageViewShadow, targetScale
					+ shadowAdjustScaleX);
			ViewHelper.setScaleY(imageViewShadow, targetScale
					+ shadowAdjustScaleY);
			ViewHelper.setAlpha(scrollViewMenu, (1 - targetScale) * 2.0f);

			lastRawX = ev.getRawX();
			return true;
		}

		break;

	case MotionEvent.ACTION_UP:

		if (isInIgnoredView)
			break;
		if (pressedState != PRESSED_MOVE_HORIZANTAL)
			break;

		pressedState = PRESSED_DONE;
		if (isOpened()) {
			if (currentActivityScaleX > 0.65f) // 0.56
				closeMenu();
			else
				openMenu(scaleDirection);
		} else {
			if (currentActivityScaleX < 0.90f) { // 0.94
				openMenu(scaleDirection);
			} else {
				closeMenu();
			}
		}

		break;

	}
	lastRawX = ev.getRawX();
	return super.dispatchTouchEvent(ev);
}
 
Example 14
Source File: AccordionTransformer.java    From AndroidImageSlider with MIT License 4 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
    ViewHelper.setPivotX(view,position < 0 ? 0 : view.getWidth());
    ViewHelper.setScaleX(view,position < 0 ? 1f + position : 1f - position);
}
 
Example 15
Source File: SlidingActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void setContentView(int layoutResID) {
    super.setContentView(R.layout.slide_activity_slide_layout);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mInitOffset = (1 - MIN_SCALE) * metrics.widthPixels / 2.f;

    mPreview = findViewById(R.id.iv_preview);
    FrameLayout contentView = (FrameLayout) findViewById(R.id.content_view);

    if (!hideTitle) {
        int resId = -1 == titleResId ? R.layout.slide_activity_title_layout : titleResId;
        inflater.inflate(resId, contentView);
    }

    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, Gravity.BOTTOM);
    final int marginTop = hideTitle ? 0 : (int) (metrics.density * 48.f + .5f);
    layoutParams.setMargins(0, marginTop, 0, 0);
    contentView.addView(inflater.inflate(layoutResID, null), layoutParams);

    SlidingLayout slideLayout = (SlidingLayout) findViewById(R.id.slide_layout);
    slideLayout.setShadowResource(R.drawable.slide_activity_sliding_back_shadow);
    slideLayout.setSliderFadeColor(0x00000000);
    slideLayout.setPanelSlideListener(new SlidingLayout.SimpleSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            final int sdkInt = Build.VERSION.SDK_INT;

            if (slideOffset <= 0) {
                if (sdkInt >= Build.VERSION_CODES.HONEYCOMB) {
                    mPreview.setScaleX(MIN_SCALE);
                    mPreview.setScaleY(MIN_SCALE);
                } else {
                    ViewHelper.setScaleX(mPreview, MIN_SCALE);
                    ViewHelper.setScaleY(mPreview, MIN_SCALE);
                }
            } else if (slideOffset < 1) {
                // Scale the page down (between MIN_SCALE and 1)
                float scaleFactor = MIN_SCALE + Math.abs(slideOffset) * (1 - MIN_SCALE);

                if (sdkInt >= Build.VERSION_CODES.HONEYCOMB) {
                    mPreview.setAlpha(slideOffset);
                    mPreview.setTranslationX(mInitOffset * (1 - slideOffset));
                    mPreview.setScaleX(scaleFactor);
                    mPreview.setScaleY(scaleFactor);
                } else {
                    ViewHelper.setAlpha(mPreview, slideOffset);
                    ViewHelper.setTranslationX(mPreview, mInitOffset * (1 - slideOffset));
                    ViewHelper.setScaleX(mPreview, scaleFactor);
                    ViewHelper.setScaleY(mPreview, scaleFactor);
                }
            } else {
                if (sdkInt >= Build.VERSION_CODES.HONEYCOMB) {
                    mPreview.setScaleX(1);
                    mPreview.setScaleY(1);
                    mPreview.setAlpha(1);
                    mPreview.setTranslationX(0);
                } else {
                    ViewHelper.setScaleX(mPreview, 1);
                    ViewHelper.setScaleY(mPreview, 1);
                    ViewHelper.setAlpha(mPreview, 1);
                    ViewHelper.setTranslationX(mPreview, 0);
                }
                finish();
                overridePendingTransition(0, 0);
            }
        }
    });


    byte[] byteArray = getIntent().getByteArrayExtra(IntentUtils.KEY_PREVIEW_IMAGE);
    if (null != byteArray && byteArray.length > 0) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 2;
        Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length, options);
        if (null != bmp) {
            ((ImageView) mPreview).setImageBitmap(bmp);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                mPreview.setScaleX(MIN_SCALE);
                mPreview.setScaleY(MIN_SCALE);
            } else {
                ViewHelper.setScaleX(mPreview, MIN_SCALE);
                ViewHelper.setScaleY(mPreview, MIN_SCALE);
            }
        } else {
            /** preview image captured fail, disable the slide back */
            slideLayout.setSlideable(false);
        }
    } else {
        /** preview image captured fail, disable the slide back */
        slideLayout.setSlideable(false);
    }
}
 
Example 16
Source File: ScaleAnimater.java    From JPTabBar with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageAnimate(View v,float offset){
    ViewHelper.setScaleX(v, offset*0.2f+1f);
    ViewHelper.setScaleY(v, offset*0.2f+1f);
}
 
Example 17
Source File: FlexibleSpaceWithImageGridViewActivity.java    From Android-ObservableScrollView with Apache License 2.0 4 votes vote down vote up
@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, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
    ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-scrollY / 2, minOverlayTransitionY, 0));

    // Translate list background
    ViewHelper.setTranslationY(mListBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight));

    // 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);
    setPivotXToTitle();
    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 - mFab.getHeight() / 2;
    float fabTranslationY = ScrollUtils.getFloat(
            -scrollY + mFlexibleSpaceImageHeight - mFab.getHeight() / 2,
            mActionBarSize - mFab.getHeight() / 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
Source File: ScaleAnimater.java    From JPTabBar with Apache License 2.0 4 votes vote down vote up
@Override
public void onPressDown(View v, boolean selected) {
    ViewHelper.setScaleX(v,1.1f);
    ViewHelper.setScaleY(v,1.1f);
}
 
Example 19
Source File: FlexibleSpaceWithImageScrollViewActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@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)));

    // 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: FlipPageViewTransformer.java    From ImageSliderWithSwipes with Apache License 2.0 4 votes vote down vote up
private void setSize(View view, float position, float percentage) {
    ViewHelper.setScaleX(view,(position != 0 && position != 1) ? percentage : 1);
    ViewHelper.setScaleY(view,(position != 0 && position != 1) ? percentage : 1);
}