Exemple #1
0
		private void transformViewAtIndex(int index, android.view.View view, bool animate_1
			)
		{
			float maxPerspectiveShiftY = mPerspectiveShiftY;
			float maxPerspectiveShiftX = mPerspectiveShiftX;
			if (mStackMode == ITEMS_SLIDE_DOWN)
			{
				index = mMaxNumActiveViews - index - 1;
				if (index == mMaxNumActiveViews - 1)
				{
					index--;
				}
			}
			else
			{
				index--;
				if (index < 0)
				{
					index++;
				}
			}
			float r = (index * 1.0f) / (mMaxNumActiveViews - 2);
			float scale = 1 - PERSPECTIVE_SCALE_FACTOR * (1 - r);
			float perspectiveTranslationY = r * maxPerspectiveShiftY;
			float scaleShiftCorrectionY = (scale - 1) * (getMeasuredHeight() * (1 - PERSPECTIVE_SHIFT_FACTOR_Y
				) / 2.0f);
			float transY = perspectiveTranslationY + scaleShiftCorrectionY;
			float perspectiveTranslationX = (1 - r) * maxPerspectiveShiftX;
			float scaleShiftCorrectionX = (1 - scale) * (getMeasuredWidth() * (1 - PERSPECTIVE_SHIFT_FACTOR_X
				) / 2.0f);
			float transX = perspectiveTranslationX + scaleShiftCorrectionX;
			// If this view is currently being animated for a certain position, we need to cancel
			// this animation so as not to interfere with the new transformation.
			if (view is android.widget.StackView.StackFrame)
			{
				((android.widget.StackView.StackFrame)view).cancelTransformAnimator();
			}
			if (animate_1)
			{
				android.animation.PropertyValuesHolder translationX = android.animation.PropertyValuesHolder
					.ofFloat("translationX", transX);
				android.animation.PropertyValuesHolder translationY = android.animation.PropertyValuesHolder
					.ofFloat("translationY", transY);
				android.animation.PropertyValuesHolder scalePropX = android.animation.PropertyValuesHolder
					.ofFloat("scaleX", scale);
				android.animation.PropertyValuesHolder scalePropY = android.animation.PropertyValuesHolder
					.ofFloat("scaleY", scale);
				android.animation.ObjectAnimator oa = android.animation.ObjectAnimator.ofPropertyValuesHolder
					(view, scalePropX, scalePropY, translationY, translationX);
				oa.setDuration(STACK_RELAYOUT_DURATION);
				if (view is android.widget.StackView.StackFrame)
				{
					((android.widget.StackView.StackFrame)view).setTransformAnimator(oa);
				}
				oa.start();
			}
			else
			{
				view.setTranslationX(transX);
				view.setTranslationY(transY);
				view.setScaleX(scale);
				view.setScaleY(scale);
			}
		}
Exemple #2
0
			internal virtual android.graphics.Bitmap createOutline(android.view.View v, int type
				, int color)
			{
				mHolographicPaint.setColor(color);
				if (type == RES_OUT)
				{
					mBlurPaint.setMaskFilter(mSmallBlurMaskFilter);
				}
				else
				{
					if (type == CLICK_FEEDBACK)
					{
						mBlurPaint.setMaskFilter(mLargeBlurMaskFilter);
					}
				}
				if (v.getMeasuredWidth() == 0 || v.getMeasuredHeight() == 0)
				{
					return null;
				}
				android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(v.getMeasuredWidth
					(), v.getMeasuredHeight(), android.graphics.Bitmap.Config.ARGB_8888);
				mCanvas.setBitmap(bitmap);
				float rotationX = v.getRotationX();
				float rotation = v.getRotation();
				float translationY = v.getTranslationY();
				float translationX = v.getTranslationX();
				v.setRotationX(0);
				v.setRotation(0);
				v.setTranslationY(0);
				v.setTranslationX(0);
				v.draw(mCanvas);
				v.setRotationX(rotationX);
				v.setRotation(rotation);
				v.setTranslationY(translationY);
				v.setTranslationX(translationX);
				drawOutline(mCanvas, bitmap);
				mCanvas.setBitmap(null);
				return bitmap;
			}