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

The following are Jave code examples for showing how to use setScaleX() 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.
+ Save this method
Example 1
Project: Carousel   File: DepthPageTransformer.java   View Source Code Vote up 8 votes
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.setTranslationX(0);
        view.setScaleX(1);
        view.setScaleY(1);
    } 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);

    } else { // (1,+Infinity]
        view.setAlpha(0);
    }
}
 
Example 2
Project: AndroidBasicLibs   File: ABaseTransformer.java   View Source Code 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: GxIconDIY   File: SimplePageTransformer.java   View Source Code Vote up 6 votes
private void setSize(View view, float position, float percentage) {
    if (percentage < 0.85f) {
        percentage = 0.85f;
    }
    view.setScaleX((position != 0 && position != 1) ? percentage : 1);
    view.setScaleY((position != 0 && position != 1) ? percentage : 1);
}
 
Example 4
Project: GeekZone   File: DepthPageTransformer.java   View Source Code 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: AndroidViewPagerRxJava   File: ZoomOutTranformer.java   View Source Code Vote up 6 votes
@Override
protected void onTransform(View view, float position) {
	final float scale = 1f + Math.abs(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));
	if(position == -1){
		view.setTranslationX(view.getWidth() * -1);
	}
}
 
Example 6
Project: GitHub   File: ForegroundToBackgroundTransformer.java   View Source Code 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 7
Project: BlackList   File: Utils.java   View Source Code Vote up 6 votes
/**
 * Scales passed view with passed dimension on Tablets only
 */
public static void scaleViewOnTablet(Context context, View view, @DimenRes int dimenRes) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        boolean isTablet = context.getResources().getBoolean(R.bool.isTablet);
        if (isTablet) {
            TypedValue outValue = new TypedValue();
            context.getResources().getValue(dimenRes, outValue, true);
            float scale = outValue.getFloat();
            view.setScaleX(scale);
            view.setScaleY(scale);
        }
    }
}
 
Example 8
Project: Mybilibili   File: ForegroundToBackgroundTransformer.java   View Source Code 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 9
Project: BannerView   File: BackgroundToForegroundTransformer.java   View Source Code 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 10
Project: GitHub   File: ForegroundToBackgroundTransformer.java   View Source Code 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 11
Project: Viajes   File: AddImageAdapter.java   View Source Code Vote up 6 votes
private void setAnimation(final View view, int position) {
    if (position > mAnimationPosition) {
        view.setScaleX(0f);
        view.setScaleY(0f);
        view.animate()
                .scaleX(1f)
                .scaleY(1f)
                .setDuration(300)
                .setInterpolator(new DecelerateInterpolator());

        mAnimationPosition = position;
    }
}
 
Example 12
Project: garras   File: DefaultPageAnimator.java   View Source Code Vote up 6 votes
@Override
protected void transformForegroundPage(View page, float position,
        boolean enter) {
    page.setTranslationX(0);
    page.setAlpha(1);
    page.setScaleX(1);
    page.setScaleY(1);
}
 
Example 13
Project: GitHub   File: ForegroundToBackgroundTransformer.java   View Source Code 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 14
Project: boohee_v5.6   File: ViewPropertyAnimatorHC.java   View Source Code Vote up 6 votes
private void setValue(int propertyConstant, float value) {
    View v = (View) this.mView.get();
    if (v != null) {
        switch (propertyConstant) {
            case 1:
                v.setTranslationX(value);
                return;
            case 2:
                v.setTranslationY(value);
                return;
            case 4:
                v.setScaleX(value);
                return;
            case 8:
                v.setScaleY(value);
                return;
            case 16:
                v.setRotation(value);
                return;
            case 32:
                v.setRotationX(value);
                return;
            case 64:
                v.setRotationY(value);
                return;
            case 128:
                v.setX(value);
                return;
            case 256:
                v.setY(value);
                return;
            case 512:
                v.setAlpha(value);
                return;
            default:
                return;
        }
    }
}
 
Example 15
Project: Mobike   File: HelpCardActivity.java   View Source Code Vote up 6 votes
public void transformPage(View view, float position) {
    Log.d("DepthPageTransformer", view.getTag() + " , " + position + "");
    int pageWidth = view.getWidth();

    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(0);
        view.setScaleX(1);
        view.setScaleY(1);

    } else if (position <= 1) { // (0,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 { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
Example 16
Project: AndroidViewPagerRxJava   File: DepthPageTransformer.java   View Source Code 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 17
Project: ImitateZHRB   File: AccordionTransformer.java   View Source Code Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	view.setPivotX(position < 0 ? 0 : view.getWidth());
	view.setScaleX(position < 0 ? 1f + position : 1f - position);
}
 
Example 18
Project: StepDialog   File: ZoomOutPageTransformer.java   View Source Code Vote up 5 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 19
Project: CommentView   File: ViewUtils.java   View Source Code Vote up 5 votes
public static void setScaleX(View view, float f) {
    if (view != null && Build.VERSION.SDK_INT >= 11) {
        view.setScaleX(f);
    }
}
 
Example 20
Project: Orin   File: FlatPlayerPlaybackControlsFragment.java   View Source Code Vote up 5 votes
private static void prepareForAnimation(View view) {
    if (view != null) {
        view.setScaleX(0f);
        view.setScaleY(0f);
    }
}