Java Code Examples for android.view.View.setScaleY()

The following are Jave code examples for showing how to use setScaleY() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: PageTransformerHelp   File: CascadingPageTransformer.java   Source Code and License Vote up 7 votes
@SuppressLint("NewApi")
public void transformPage(View page, float position) {
    if (position <= 0.0f) {//被滑动的那页  position 是-下标~ 0
        page.setTranslationX(0f);
        //旋转角度  45° * -0.1 = -4.5°
        page.setRotation((45 * position));
        //X轴偏移 li:  300/3 * -0.1 = -10
        page.setTranslationX((page.getWidth() / 3 * position));
    } else {
        //缩放比例
        float scale = (page.getWidth() - mScaleOffset * position) / (float) (page.getWidth());

        page.setScaleX(scale);
        page.setScaleY(scale);

        page.setTranslationX((-page.getWidth() * position));
        page.setTranslationY((mScaleOffset * 0.8f) * position);
    }
}
 
Example 2
Project: GitHub   File: ABaseTransformer.java   Source Code and License Vote up 7 votes
/**
	 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
	 * <p>
	 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
	 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
	 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
	 * alpha.
	 *
	 * @param page
	 *            Apply the transformation to this page
	 * @param position
	 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
	 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
	 */
	protected void onPreTransform(View page, float position) {
		final float width = page.getWidth();

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

		if (hideOffscreenPages()) {
			page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
//			page.setEnabled(false);
		} else {
//			page.setEnabled(true);
			page.setAlpha(1f);
		}
	}
 
Example 3
Project: FreeStreams-TVLauncher   File: FocusedBasePositionManager.java   Source Code and License Vote up 7 votes
private void scaleSelectedView() {
	View localView = getSelectedView();
	if (localView != null) {
		float f1 = this.mScaleXValue - 1.0F;
		float f2 = this.mScaleYValue - 1.0F;
		int i = this.mFrameRate;
		int j = this.mCurrentFrame;
		if (1 == this.mode) {
			i = this.mScaleFrameRate;
			j -= this.mFocusFrameRate;
			if (j <= 0) {
				return;
			}
		}
		float f3 = 1.0F + f1 * j / i;
		float f4 = 1.0F + f2 * j / i;
		localView.setScaleX(f3);
		localView.setScaleY(f4);
	}
}
 
Example 4
Project: ImitateZHRB   File: DepthPageTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	if (position <= 0f) {
		view.setTranslationX(0f);
		view.setScaleX(1f);
		view.setScaleY(1f);
	} else if (position <= 1f) {
		final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
		view.setAlpha(1 - position);
		view.setPivotY(0.5f * view.getHeight());
		view.setTranslationX(view.getWidth() * -position);
		view.setScaleX(scaleFactor);
		view.setScaleY(scaleFactor);
	}
}
 
Example 5
Project: ImitateZHRB   File: ZoomInTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
}
 
Example 6
Project: LuaViewPlayground   File: UDView.java   Source Code and License Vote up 6 votes
/**
 * 缩放
 *
 * @param scaleX
 * @param scaleY
 * @return
 */
public UDView setScale(float scaleX, float scaleY) {
    final View view = getView();
    if (view != null) {
        view.setScaleX(scaleX);
        view.setScaleY(scaleY);
    }
    return this;
}
 
Example 7
Project: BannerView   File: ZoomOutSlideTransformer.java   Source Code and License Vote up 6 votes
@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 width = view.getWidth();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = width * (1 - scaleFactor) / 2;

		// Center vertically
		view.setPivotY(0.5f * height);
		view.setPivotX(0.5f * width);

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

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

		// Fade the page relative to its size.
		view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
	}
}
 
Example 8
Project: PageTransformerHelp   File: ScaleInOutTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0 ? 0 : view.getWidth());
	view.setPivotY(view.getHeight() / 2f);
	float scale = position < 0 ? 1f + position : 1f - position;
	view.setScaleX(scale);
	view.setScaleY(scale);
}
 
Example 9
Project: ECardFlow   File: CardFlowTransformer.java   Source Code and License Vote up 6 votes
@Override
public void transformPage(View page, float position) {
    final float height = page.getHeight();
    final float width = page.getWidth();
    page.setPivotY(0.5f * height);
    page.setPivotX(0.5f * width);
    if (position >= -2 && position <= 2) {
        float mFraction = mDirection * (float) Math.abs(Math.sin(Math.PI * position));
        page.setRotationY(mFraction * mMaxRotateY);
        page.setScaleX(PAGE_SCALE);
        page.setScaleY(PAGE_SCALE);
    }
}
 
Example 10
Project: AdPlayBanner   File: ZoomOutPageTransformer.java   Source Code and License Vote up 6 votes
@SuppressLint("NewApi")
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    Log.e("TAG", view + " , " + position + "");

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);

    } else if (position <= 1) { //a页滑动至b页 ; a页从 0.0 -1 ;b页从1 ~ 0.0
        // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 2);
        }

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

        // Fade the page relative to its size.
        view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE)
                / (1 - MIN_SCALE) * (1 - MIN_ALPHA));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
Example 11
Project: photo-editor-android   File: MultiTouchListener.java   Source Code and License Vote up 6 votes
private static void move(View view, TransformInfo info) {
    computeRenderOffset(view, info.pivotX, info.pivotY);
    adjustTranslation(view, info.deltaX, info.deltaY);

    float scale = view.getScaleX() * info.deltaScale;
    scale = Math.max(info.minimumScale, Math.min(info.maximumScale, scale));
    view.setScaleX(scale);
    view.setScaleY(scale);

    float rotation = adjustAngle(view.getRotation() + info.deltaAngle);
    view.setRotation(rotation);
}
 
Example 12
Project: Flashcards-Demo   File: ZoomOutPageTransformer.java   Source Code and License Vote up 6 votes
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);

    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 2);
        }

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

        // Fade the page relative to its size.
        view.setAlpha(MIN_ALPHA +
                (scaleFactor - MIN_SCALE) /
                        (1 - MIN_SCALE) * (1 - MIN_ALPHA));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
Example 13
Project: ShotsNewsApp   File: VerticalViewPager.java   Source Code and License Vote up 6 votes
public void transformPage(View view, float position) {
            int pageWidth = view.getWidth();

//            view.setBackgroundColor(Color.parseColor("RED"));
            if (position < -1) { // [-Infinity,-1)
                // This page is way off-screen to the left.
                view.setAlpha(0);



            } else if (position <= 0) { // [-1,0]
                // Use the default slide transition when moving to the left page
                view.setAlpha(1);
                //view.setTranslationX(1);
                view.setScaleX(1);
                view.setScaleY(1);
                float yPosition = position * view.getHeight();
                view.setTranslationY(yPosition);
                view.setTranslationX(-1 * view.getWidth() * position);


            } else if (position <= 1) { // (0,1]
                // Fade the page out.
                view.setAlpha(1-position);

                view.setTranslationX(-1 * view.getWidth() * 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 { // (1,+Infinity]
                // This page is way off-screen to the right.
                view.setAlpha(0);
            }

        }
 
Example 14
Project: GitHub   File: ZoomOutSlideTransformer.java   Source Code and License Vote up 6 votes
@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 width = view.getWidth();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = width * (1 - scaleFactor) / 2;

		// Center vertically
		view.setPivotY(0.5f * height);
		view.setPivotX(0.5f * width);

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

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

		// Fade the page relative to its size.
		view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
	}
}
 
Example 15
Project: BannerView   File: BackgroundToForegroundTransformer.java   Source Code and License Vote up 6 votes
@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);

	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(width * 0.5f);
	view.setPivotY(height * 0.5f);
	view.setTranslationX(position < 0 ? width * position : -width * position * 0.25f);
}
 
Example 16
Project: AndroidViewPagerRxJava   File: ScaleInOutTransformer.java   Source Code and License Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0 ? 0 : view.getWidth());
	view.setPivotY(view.getHeight() / 2f);
	float scale = position < 0 ? 1f + position : 1f - position;
	view.setScaleX(scale);
	view.setScaleY(scale);
}
 
Example 17
Project: android-project-gallery   File: ImageRecommendView.java   Source Code and License Vote up 5 votes
@SuppressLint("NewApi")
		public void transformPage(View view, float position)
		{
			int pageWidth = view.getWidth();

			if (position < -1)
			{
				// 页面正在向左离开屏幕 [-Infinity,-1)
				view.setAlpha(0);
			}
			else if (position <= 0)
			{
				// 使用正常的滑动效果,[-1,0]
				view.setAlpha(1);
				view.setScaleX(1);
				view.setScaleY(1);
				
				view.setTranslationX(pageWidth * -position);

			}
			else if (position <= 1)
			{
//				// 渐隐(0,1]
//				view.setAlpha(1 - position);
//
//				// 抵消默认的滑动
//				view.setTranslationX(pageWidth * -position);
//
//				// 按比例缩小图片
//				float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
//				view.setScaleX(scaleFactor);
//				view.setScaleY(scaleFactor);
				
				view.setAlpha(1);
				view.setScaleX(1);
				view.setScaleY(1);
				view.setTranslationX(pageWidth * position);
				
			}
			else
			{
				// 页面向右离开屏幕(1,+Infinity]
				//view.setAlpha(0);
				
				view.setAlpha(1);
				view.setScaleX(1);
				view.setScaleY(1);
				view.setTranslationX(pageWidth * position);
			}
		}
 
Example 18
Project: JewelryUI   File: ScrollZoomLayoutManager.java   Source Code and License Vote up 5 votes
@Override
protected void setItemViewProperty(View itemView, float targetOffset) {
    float scale = calculateScale((int) targetOffset + startLeft);
    itemView.setScaleX(scale);
    itemView.setScaleY(scale);
}
 
Example 19
Project: RNLearn_Project1   File: ScaleYAnimationPropertyUpdater.java   Source Code and License Vote up 5 votes
@Override
protected void setProperty(View view, float propertyValue) {
  view.setScaleY(propertyValue);
}
 
Example 20
Project: GitHub   File: ImageItem.java   Source Code and License Vote up 3 votes
/**
 * helper method to style the heart view
 *
 * @param view
 * @param value
 */
private void style(View view, int value) {
    view.setScaleX(value);
    view.setScaleY(value);
    view.setAlpha(value);
}