Java Code Examples for android.view.View#setScaleX()
The following examples show how to use
android.view.View#setScaleX() .
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: adamant-android File: PassphraseAvatarTransformation.java License: GNU General Public License v3.0 | 6 votes |
@Override public void transformItem(View item, float position) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ImageView avatarView = item.findViewById(R.id.list_item_passphrase_avatar); float translationZ = (float) Math.abs(SELECTED_TRANSLATION_Z - ((Math.pow(2, Math.abs(position)) - 1) * SELECTED_TRANSLATION_Z)); avatarView.setTranslationZ(translationZ); } pivotX.setOn(item); pivotY.setOn(item); float closenessToCenter = 1f - Math.abs(position); float scale = minScale + maxMinDiff * closenessToCenter; item.setScaleX(scale); item.setScaleY(scale); }
Example 2
Source Project: android-viewpager-transformers File: BaseTransformer.java License: Apache License 2.0 | 6 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(); view.setRotationX(0); view.setRotationY(0); view.setRotation(0); view.setScaleX(1); view.setScaleY(1); view.setPivotX(0); view.setPivotY(0); view.setTranslationY(0); view.setTranslationX(isPagingEnabled() ? 0f : -width * position); if (hideOffscreenPages()) { view.setAlpha(position <= -1f || position >= 1f ? 0f : 1f); } else { view.setAlpha(1f); } }
Example 3
Source Project: android-viewpager-transformers File: ZoomOutSlideTransformer.java License: Apache License 2.0 | 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 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 view.setPivotY(0.5f * height); 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 4
Source Project: android-BatchStepSensor File: CardStreamLinearLayout.java License: Apache License 2.0 | 5 votes |
private void resetAnimatedView(View child) { child.setAlpha(1.f); child.setTranslationX(0.f); child.setTranslationY(0.f); child.setRotation(0.f); child.setRotationY(0.f); child.setRotationX(0.f); child.setScaleX(1.f); child.setScaleY(1.f); }
Example 5
Source Project: XBanner File: ZoomPageTransformer.java License: Apache License 2.0 | 5 votes |
@Override public void handleRightPage(View view, float position) { float scale = Math.max(mMinScale, 1 - position); float vertMargin = view.getHeight() * (1 - scale) / 2; float horzMargin = view.getWidth() * (1 - scale) / 2; view.setTranslationX( -horzMargin + vertMargin / 2); view.setScaleX( scale); view.setScaleY( scale); view.setAlpha( mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha)); }
Example 6
Source Project: Banner File: DepthPageTransformer.java License: Apache License 2.0 | 5 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 7
Source Project: Trebuchet File: Overview.java License: GNU General Public License v3.0 | 5 votes |
@Override public void screenScrolled(View v, float progress) { float scale =1.0f - 0.1f * mScaleInterpolator .getInterpolation(Math.min(0.3f, Math.abs(progress)) / 0.3f); v.setPivotX(progress < 0 ? 0 : v.getMeasuredWidth()); v.setPivotY(v.getMeasuredHeight() * 0.5f); v.setScaleX(scale); v.setScaleY(scale); v.setAlpha(scale); }
Example 8
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 9
Source Project: dingo File: FloatingView.java License: GNU General Public License v3.0 | 5 votes |
/** * 拡大・縮小を行います。 * * @param newScale 設定する拡大率 */ private void setScale(float newScale) { // INFO:childにscaleを設定しないと拡大率が変わらない現象に対処するための修正 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View targetView = getChildAt(i); targetView.setScaleX(newScale); targetView.setScaleY(newScale); } } else { setScaleX(newScale); setScaleY(newScale); } }
Example 10
Source Project: ETHWallet File: AddWalletView.java License: GNU General Public License v3.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 11
Source Project: AndroidAnimationExercise File: VPAnim2Activity.java License: Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") public void transformPage(View view, float position) { int pageWidth = view.getMeasuredWidth(); int pageHeight = view.getMeasuredHeight(); Log.e("TAG", view + " , " + position + ""); if (position < -1) { // [-Infinity,-1) // This page is way off-screen to the left. view.setScaleX(MIN_SCALE); view.setScaleY(MIN_SCALE); view.setPivotX(pageWidth); } else if (position <= 1) //a页滑动至b页 ; a页从 0.0 -1 ;b页从1 ~ 0.0 { // [-1,1] float scaleFactor; if (position < 0) { scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 + position); } else { scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - position); } // Scale the page down (between MIN_SCALE and 1) view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); view.setPivotX(pageWidth * CENTER * (1 - position)); } else { // (1,+Infinity] // This page is way off-screen to the right. view.setPivotX(0); view.setScaleX(MIN_SCALE); view.setScaleY(MIN_SCALE); } }
Example 12
Source Project: AcDisplay File: AcDisplayFragment.java License: GNU General Public License v2.0 | 5 votes |
/** * Updates the visibility of divider between * the scene and icons. */ @SuppressLint("NewApi") private void updateDividerVisibility(boolean animate) { final View view = mDividerView; final boolean visible = view.getVisibility() == View.VISIBLE; final boolean visibleNow = !mWidgetsMap.isEmpty(); if (animate && isAnimatable()) { int visibleInt = MathUtils.bool(visible); int visibleNowInt = MathUtils.bool(visibleNow); float[] values = {1.0f, 0.1f, 1.0f, 0.5f}; ViewUtils.setVisible(view, true); view.setScaleX(values[1 - visibleInt]); view.setAlpha(values[3 - visibleInt]); view.animate() .scaleX(values[1 - visibleNowInt]) .alpha(values[3 - visibleNowInt]) .setInterpolator(new AccelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); ViewUtils.setVisible(view, visibleNow, View.INVISIBLE); view.setAlpha(1); view.setScaleX(1); } }); } else { ViewUtils.setVisible(view, visibleNow, View.INVISIBLE); } }
Example 13
Source Project: iBeebo File: ZoomOutPageTransformer.java License: GNU General Public License v3.0 | 5 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 14
Source Project: FragmentMaster File: EnterOvershootAnimator.java License: Apache License 2.0 | 5 votes |
@Override protected void transformForegroundPage(View page, float position, boolean enter) { float offset = 0; if (enter) { // Perform overshot animation if enter. offset = page.getWidth() * ((1 - position) - sInterpolator .getInterpolation(1 - position)); } page.setTranslationX(offset); page.setAlpha(1); page.setScaleX(1); page.setScaleY(1); }
Example 15
Source Project: newsApp File: DepthPageTransformer.java License: Apache License 2.0 | 5 votes |
@Override public void transformPage(View view, float position) { int pageWidth = view.getWidth(); int pageHeight = view.getHeight(); float alpha = 0; if (0 <= position && position <= 1) { alpha = 1 - position; } else if (-1 < position && position < 0) { float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); float verticalMargin = pageHeight * (1 - scaleFactor) / 2; float horizontalMargin = pageWidth * (1 - scaleFactor) / 2; if (position < 0) { view.setTranslationX(horizontalMargin - verticalMargin / 2); } else { view.setTranslationX(-horizontalMargin + verticalMargin / 2); } view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); alpha = position + 1; } view.setAlpha(alpha); view.setTranslationX(view.getWidth() * -position); float yPosition = position * view.getHeight(); view.setTranslationY(yPosition); }
Example 16
Source Project: WanAndroid File: ForegroundToBackgroundTransformer.java License: GNU General Public License v3.0 | 5 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 17
Source Project: UltimateAndroid File: ForegroundToBackgroundTransformer.java License: Apache License 2.0 | 5 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 18
Source Project: AndroidAnimationExercise File: ZoomOutPageTransformer.java License: Apache License 2.0 | 4 votes |
@SuppressLint("NewApi") public void transformPage(View view, float position) { int pageWidth = view.getMeasuredWidth(); int pageHeight = view.getMeasuredHeight(); Log.e("TAG", view + " , " + position + ""); if (position < -1) { // [-Infinity,-1) // This page is way off-screen to the left. view.setAlpha(1); } 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(1); } }
Example 19
Source Project: MiBandDecompiled File: a.java License: Apache License 2.0 | 4 votes |
static void g(View view, float f1) { view.setScaleX(f1); }
Example 20
Source Project: BannerPager File: AccordionTransformer.java License: Apache License 2.0 | 4 votes |
@Override protected void onTransform(View view, float position) { view.setPivotX(position < 0 ? 0 : view.getWidth()); view.setScaleX(position < 0 ? 1f + position : 1f - position); }