Java Code Examples for android.view.View#setScaleY()
The following examples show how to use
android.view.View#setScaleY() .
These examples are extracted from open source projects.
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 Project: GalleryLayoutManager File: CurveTransformer.java License: Apache License 2.0 | 6 votes |
@Override public void transformItem(GalleryLayoutManager layoutManager, View item, float fraction) { if (layoutManager.getOrientation() == GalleryLayoutManager.VERTICAL) { return; } int width = item.getWidth(); int height = item.getHeight(); item.setPivotX(width / 2.f); item.setPivotY(height); float scale = 1 - 0.1f * Math.abs(fraction); item.setScaleX(scale); item.setScaleY(scale); item.setRotation(ROTATE_ANGEL * fraction); item.setTranslationY((float) (Math.sin(2 * Math.PI * ROTATE_ANGEL * Math.abs(fraction) / 360.f) * width / 2.0f)); item.setTranslationX((float) ((1 - scale) * width / 2.0f / Math.cos(2 * Math.PI * ROTATE_ANGEL * fraction / 360.f))); if (fraction > 0) { item.setTranslationX(-item.getTranslationX()); } item.setAlpha(1 - 0.2f * Math.abs(fraction)); }
Example 2
Source Project: duo-navigation-drawer File: DuoDrawerLayout.java License: Apache License 2.0 | 6 votes |
/** * Show the the touch interceptor. */ private void showTouchInterceptor() { if (findViewWithTag(TAG_OVERLAY) == null) { addTouchInterceptor(); } if (mContentView == null) { mContentView = findViewWithTag(TAG_CONTENT); } float offset = map(mContentView.getLeft(), 0, DuoDrawerLayout.this.getWidth() * mMarginFactor, 0, 1); float scaleFactorContent = map(offset, 0, 1, mContentScaleClosed, mClickToCloseScale); View interceptor = findViewWithTag(TAG_OVERLAY); if (interceptor != null) { interceptor.setTranslationX(mContentView.getLeft()); interceptor.setTranslationY(mContentView.getTop()); interceptor.setScaleX(scaleFactorContent); interceptor.setScaleY(scaleFactorContent); interceptor.setVisibility(VISIBLE); } }
Example 3
Source Project: WanAndroid File: ABaseTransformer.java License: GNU General Public License v3.0 | 6 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 4
Source Project: AndroidProject File: PickerLayoutManager.java License: Apache License 2.0 | 6 votes |
/** * 竖向方向上的缩放 */ private void scaleVerticalChildView(){ float mid = getHeight() / 2.0f; for (int i = 0; i < getChildCount(); i++) { View childView = getChildAt(i); if (childView != null) { float childMid = (getDecoratedTop(childView) + getDecoratedBottom(childView)) / 2.0f; float scale = 1.0f + (-1 * (1 - mScale)) * (Math.min(mid, Math.abs(mid - childMid))) / mid; childView.setScaleX(scale); childView.setScaleY(scale); if (mAlpha) { childView.setAlpha(scale); } } } }
Example 5
Source Project: Pretty-Zhihu File: DepthPageTransformer.java License: Apache License 2.0 | 5 votes |
public void transformPage(View view, float 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 6
Source Project: FlexibleAdapter File: FlexibleItemAnimator.java License: Apache License 2.0 | 5 votes |
private static void clear(View v) { v.setAlpha(1); v.setScaleY(1); v.setScaleX(1); v.setTranslationY(0); v.setTranslationX(0); v.setRotation(0); v.setRotationY(0); v.setRotationX(0); v.setPivotY(v.getMeasuredHeight() / 2); v.setPivotX(v.getMeasuredWidth() / 2); v.animate().setInterpolator(null).setStartDelay(0); }
Example 7
Source Project: NanoIconPack File: SimplePageTransformer.java License: Apache License 2.0 | 5 votes |
private void transformPageDepth(View view, float position) { final float MIN_SCALE = 0.75f; 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 8
Source Project: PageTransformerHelp File: ZoomOutSlideTransformer.java License: Apache License 2.0 | 5 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 9
Source Project: StackOverView File: OverviewCardTransform.java License: MIT License | 5 votes |
/** Reset the transform on a view. */ public static void reset(View v) { v.setTranslationX(0f); v.setTranslationY(0f); v.setScaleX(1f); v.setScaleY(1f); v.setAlpha(1f); }
Example 10
Source Project: floatingMenu File: FloatingMenuAnimationHandler.java License: Apache License 2.0 | 5 votes |
private void resetSubButton(Point center, SubButton subButton, View subButtonView) { if (subButton != null) { int floatingMenuButtonWidth = floatingMenuButton.getWidth(); int floatingMenuButtonHeight = floatingMenuButton.getHeight(); int xResetPos = center.x + floatingMenuButtonWidth / 2; int yResetPos = center.y - floatingMenuButtonHeight / 2; subButtonView.setX(xResetPos); subButtonView.setY(yResetPos); subButtonView.setScaleX(0); subButtonView.setScaleY(0); subButton.setX(xResetPos); subButton.setY(yResetPos); subButton.setAlpha(0); } }
Example 11
Source Project: scene File: AnimatorUtilityTests.java License: Apache License 2.0 | 5 votes |
@Test public void testCaptureViewStatus() { ActivityController<NavigationSourceUtility.TestActivity> controller = Robolectric.buildActivity(NavigationSourceUtility.TestActivity.class).create().start().resume(); NavigationSourceUtility.TestActivity testActivity = controller.get(); View view = new View(testActivity); view.setTranslationX(1); view.setTranslationY(1); view.setScaleX(2.0f); view.setScaleY(2.0f); view.setRotation(1.0f); view.setRotationX(1.0f); view.setRotationY(1.0f); view.setAlpha(0.5f); AnimatorUtility.AnimatorInfo animatorInfo = AnimatorUtility.captureViewStatus(view); assertEquals(1.0f, animatorInfo.translationX, 0.0f); assertEquals(1.0f, animatorInfo.translationY, 0.0f); assertEquals(2.0f, animatorInfo.scaleX, 0.0f); assertEquals(2.0f, animatorInfo.scaleY, 0.0f); assertEquals(1.0f, animatorInfo.rotation, 0.0f); assertEquals(1.0f, animatorInfo.rotationX, 0.0f); assertEquals(1.0f, animatorInfo.rotationY, 0.0f); assertEquals(0.5f, animatorInfo.alpha, 0.0f); View view2 = new View(testActivity); AnimatorUtility.resetViewStatus(view2, animatorInfo); assertEquals(1.0f, view2.getTranslationX(), 0.0f); assertEquals(1.0f, view2.getTranslationY(), 0.0f); assertEquals(2.0f, view2.getScaleX(), 0.0f); assertEquals(2.0f, view2.getScaleY(), 0.0f); assertEquals(1.0f, view2.getRotation(), 0.0f); assertEquals(1.0f, view2.getRotationX(), 0.0f); assertEquals(1.0f, view2.getRotationY(), 0.0f); assertEquals(0.5f, view2.getAlpha(), 0.0f); }
Example 12
Source Project: AndroidFloatLabel File: MainActivity.java License: Apache License 2.0 | 5 votes |
@Override public void onHideLabel(View label) { final float shift = label.getWidth() / 2; label.setScaleX(SCALE_X_SHOWN); label.setScaleY(SCALE_Y_SHOWN); label.setX(0f); label.animate().alpha(0).scaleX(SCALE_X_HIDDEN).scaleY(SCALE_Y_HIDDEN).x(shift); }
Example 13
Source Project: AndroidFloatLabel File: MainActivity.java License: Apache License 2.0 | 5 votes |
@Override public void onHideLabel(View label) { final float shift = label.getWidth() / 2; label.setScaleX(SCALE_X_SHOWN); label.setScaleY(SCALE_Y_SHOWN); label.setX(0f); label.animate().alpha(0).scaleX(SCALE_X_HIDDEN).scaleY(SCALE_Y_HIDDEN).x(shift); }
Example 14
Source Project: loaned-android File: LoanHistoryActivity.java License: Apache License 2.0 | 5 votes |
@Override public void transformPage(View view, float 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 15
Source Project: FloatMenuSample File: MyFloatDialog.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void resetLogoViewSize(int hintLocation, View logoView) { logoView.clearAnimation(); logoView.setTranslationX(0); logoView.setScaleX(1); logoView.setScaleY(1); }
Example 16
Source Project: Social File: DefaultTransformer.java License: Apache License 2.0 | 5 votes |
@Override public void transformPage(View view, float arg1) { view.setAlpha(1); view.setTranslationX(0); view.setTranslationY(0); view.setPivotX(view.getWidth() / 2); view.setPivotY(view.getHeight() / 2); view.setScaleX(1); view.setScaleY(1); view.setRotation(0); }
Example 17
Source Project: PagedHeadListView File: ScalePageTransformer.java License: Apache License 2.0 | 4 votes |
@Override public void transformPage(View page, float position) { final float normalizedposition = Math.abs(Math.abs(position) - 1); page.setScaleX(normalizedposition / 2 + 0.5f); page.setScaleY(normalizedposition / 2 + 0.5f); }
Example 18
Source Project: mobile-sdk-android File: BannerAdView.java License: Apache License 2.0 | 4 votes |
@SuppressLint("NewApi") @SuppressWarnings("deprecation") protected void expandToFitScreenWidth(int adWidth, int adHeight, View view) { //Determine the width of the screen WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); @SuppressWarnings("UnusedAssignment") int width = -1; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point p = new Point(); display.getSize(p); width = p.x; } else { width = display.getWidth(); } float ratio_delta = ((float) width) / ((float) adWidth); int new_height = (int) Math.floor(adHeight * ratio_delta); if(getLayoutParams() != null) { oldH = getLayoutParams().height; oldW = getLayoutParams().width; //Adjust width of container if (getLayoutParams().width > 0 || getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT) { getLayoutParams().width = width; } //Adjust height of container getLayoutParams().height = new_height; } if(view instanceof WebView) { //Adjust height of webview if (view.getLayoutParams() == null) { view.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); } else { view.getLayoutParams().width = FrameLayout.LayoutParams.MATCH_PARENT; view.getLayoutParams().height = FrameLayout.LayoutParams.MATCH_PARENT; } ((WebView)view).setInitialScale((int) Math.ceil(ratio_delta * 100)); }else{ int adWidthInPixel = ViewUtil.getValueInPixel(getContext(), adWidth); float widthRatio = (float) width / (float) adWidthInPixel; view.setScaleX(widthRatio); view.setScaleY(widthRatio); } view.invalidate(); shouldResetContainer = true; }
Example 19
Source Project: CircularReveal File: DynamicAnimation.java License: MIT License | 4 votes |
@Override public void setValue(View view, float value) { view.setScaleY(value); }
Example 20
Source Project: Mover File: ViewPropertyAnimatorHC.java License: Apache License 2.0 | 4 votes |
/** * This method handles setting the property values directly in the View object's fields. * propertyConstant tells it which property should be set, value is the value to set * the property to. * * @param propertyConstant The property to be set * @param value The value to set the property to */ private void setValue(int propertyConstant, float value) { //final View.TransformationInfo info = mView.mTransformationInfo; View v = mView.get(); if (v != null) { switch (propertyConstant) { case TRANSLATION_X: //info.mTranslationX = value; v.setTranslationX(value); break; case TRANSLATION_Y: //info.mTranslationY = value; v.setTranslationY(value); break; case ROTATION: //info.mRotation = value; v.setRotation(value); break; case ROTATION_X: //info.mRotationX = value; v.setRotationX(value); break; case ROTATION_Y: //info.mRotationY = value; v.setRotationY(value); break; case SCALE_X: //info.mScaleX = value; v.setScaleX(value); break; case SCALE_Y: //info.mScaleY = value; v.setScaleY(value); break; case X: //info.mTranslationX = value - v.mLeft; v.setX(value); break; case Y: //info.mTranslationY = value - v.mTop; v.setY(value); break; case ALPHA: //info.mAlpha = value; v.setAlpha(value); break; } } }