下面列出了怎么用android.graphics.Matrix的API类实例代码及写法,或者点击链接到github查看源代码。
private void prepare() {
int width = getWidth();
int height = getHeight();
width = Math.max(width, 1);
height = Math.max(height, 1);
if (mBitmap == null || mBitmap.getWidth() != width || mBitmap.getHeight() != height) {
mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
}
getLocationInWindow(mLocationInWindow);
mCanvas.restoreToCount(1);
mCanvas.setBitmap(mBitmap);
mCanvas.setMatrix(new Matrix());
mCanvas.translate(-mLocationInWindow[0], -mLocationInWindow[1]);
mCanvas.save();
getRootView().draw(mCanvas);
}
private void sharedConstructing(Context context) {
super.setClickable(true);
this.context = context;
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
mGestureDetector = new GestureDetector(context, new GestureListener());
matrix = new Matrix();
prevMatrix = new Matrix();
m = new float[9];
normalizedScale = 1;
if (mScaleType == null) {
mScaleType = ScaleType.FIT_CENTER;
}
minScale = 1;
maxScale = 3;
superMinScale = SUPER_MIN_MULTIPLIER * minScale;
superMaxScale = SUPER_MAX_MULTIPLIER * maxScale;
setImageMatrix(matrix);
setScaleType(ScaleType.MATRIX);
setState(State.NONE);
onDrawReady = false;
super.setOnTouchListener(new PrivateOnTouchListener());
}
private void init() {
mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
//等比例缩放图片
thumbImageLeft = BitmapFactory.decodeResource(getResources(), R.drawable.video_trim_handle);
int width = thumbImageLeft.getWidth();
int height = thumbImageLeft.getHeight();
int newWidth = dip2px(11);
int newHeight = dip2px(60);
float scaleWidth = newWidth * 1.0f / width;
float scaleHeight = newHeight * 1.0f / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
thumbImageLeft = Bitmap.createBitmap(thumbImageLeft, 0, 0, width, height, matrix, true);
thumbImageRight = thumbImageLeft;
thumbPressedImage = thumbImageLeft;
thumbWidth = newWidth;
thumbHalfWidth = thumbWidth / 2;
mBitmapBlack = BitmapFactory.decodeResource(getResources(), R.drawable.upload_overlay_black);
mBitmapPro = BitmapFactory.decodeResource(getResources(), R.drawable.upload_overlay_trans);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
rectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
rectPaint.setStyle(Paint.Style.FILL);
rectPaint.setColor(Color.parseColor("#ffffff"));
}
private void sharedConstructing(Context context) {
super.setClickable(true);
this.context = context;
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
mGestureDetector = new GestureDetector(context, new GestureListener());
matrix = new Matrix();
prevMatrix = new Matrix();
m = new float[9];
normalizedScale = 1;
if (mScaleType == null) {
mScaleType = ScaleType.FIT_CENTER;
}
minScale = 1;
maxScale = 3;
superMinScale = SUPER_MIN_MULTIPLIER * minScale;
superMaxScale = SUPER_MAX_MULTIPLIER * maxScale;
setImageMatrix(matrix);
setScaleType(ScaleType.MATRIX);
setState(State.NONE);
onDrawReady = false;
super.setOnTouchListener(new PrivateOnTouchListener());
}
/**
* android.graphics.Matrixの3x3行列をOpenGLの4x4(列優先)行列に変換する
* (アフィン変換のみ)
* |a11 a12 a13| |0 1 2| |a11 a12 0 a13| |0 4 8 12|
* |a21 a22 a23| |3 4 5| |a21 a22 0 a23| |1 5 9 13|
* |a31 a32 a33| |6 7 8| => | 0 0 1 0| |2 6 10 14|
* |a31 a32 0 a33| |3 7 11 15|
* @param transform
* @param result
* @return
*/
@NonNull
@Size(min=16)
public static float[] toGLMatrix(@NonNull final Matrix transform,
@NonNull @Size(min=16) final float[] result,
@NonNull @Size(min=9) final float[] aMatrix) {
transform.getValues(aMatrix);
result[ 0] = aMatrix[Matrix.MSCALE_X];
result[ 1] = aMatrix[Matrix.MSKEW_Y];
result[ 2] = 0;
result[ 3] = aMatrix[Matrix.MPERSP_0];
result[ 4] = aMatrix[Matrix.MSKEW_X];
result[ 5] = aMatrix[Matrix.MSCALE_Y];
result[ 6] = 0;
result[ 7] = aMatrix[Matrix.MPERSP_1];
result[ 8] = 0;
result[ 9] = 0;
result[10] = 1;
result[11] = 0;
result[12] = aMatrix[Matrix.MTRANS_X];
result[13] = aMatrix[Matrix.MTRANS_Y];
result[14] = 0;
result[15] = aMatrix[Matrix.MPERSP_2];
return result;
}
/**
* Calculates the position Matrix of the asteroid to draw
* in the next frame.
*
* @param speed The speed of the asteroid.
* @param width The width of the drawing canvas.
* @param height The height of the drawing canvas.
* @return The position Matrix of the asteroid.
* Equals null if the asteroid can no longer
* be drawn within the given width/height.
*/
public Matrix next(float speed, int width, int height) {
if ((y - asteroidBitmap.getHeight()) < height) {
y += yDiff * speed;
rotation += rotationDiff;
x += xDiff * speed;
} else return null;
float left = x * width, top = y;
position = new Rect(
(int) left - (asteroidBitmap.getWidth() / 2),
(int) top - (asteroidBitmap.getHeight() / 2),
(int) left + (asteroidBitmap.getWidth() / 2),
(int) top + (asteroidBitmap.getHeight() / 2)
);
Matrix matrix = new Matrix();
matrix.postTranslate(-asteroidBitmap.getWidth() / 2, -asteroidBitmap.getHeight() / 2);
matrix.postRotate(rotation);
matrix.postTranslate(left, top);
return matrix;
}
private void init(Context context, AttributeSet attrs) {
mPaint = new Paint();
//setFilterBitmap() and setAntiAlias used together to make drawing bitmap anti-aliased.
mPaint.setFilterBitmap(true);
mPaint.setAntiAlias(true);
mMatrix = new Matrix();
bitmapDisappearDust = BitmapFactory.decodeResource(getResources(), R.drawable.icon_red_dust);
bitmapDisappearDustHalfWidth = bitmapDisappearDust.getWidth() / 2;
bitmapDisappearDustHalfHeight = bitmapDisappearDust.getHeight() / 2;
random = new Random(bitmapDisappearDust.getByteCount());
mCenterBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon_un_praised);
centerBitmapHalfWidth = mCenterBitmap.getWidth() / 2;
centerBitmapHalfHeight = mCenterBitmap.getHeight() / 2;
this.setOnTouchListener(this);
isPraised = false;
//Follow circle
outerCirclePaint = new Paint();
innerCirclePaint = new Paint();
outerCirclePaint.setStyle(Paint.Style.FILL);
outerCirclePaint.setAntiAlias(true);
innerCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
innerCirclePaint.setAntiAlias(true);
argbEvaluator = new ArgbEvaluator();
}
public RotateLoadingLayout(Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) {
super(context, mode, scrollDirection, attrs);
mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true);
mHeaderImage.setScaleType(ScaleType.MATRIX);
mHeaderImageMatrix = new Matrix();
mHeaderImage.setImageMatrix(mHeaderImageMatrix);
mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
mRotateAnimation.setRepeatCount(Animation.INFINITE);
mRotateAnimation.setRepeatMode(Animation.RESTART);
}
/**
* 执行当前outerMatrix到指定outerMatrix渐变的动画
*
* 调用此方法会停止正在进行中的手势以及手势动画.
* 当duration为0时,outerMatrix值会被立即设置而不会启动动画.
*
* @param endMatrix 动画目标矩阵
* @param duration 动画持续时间
*
* @see #getOuterMatrix(Matrix)
*/
public void outerMatrixTo(Matrix endMatrix, long duration) {
if (endMatrix == null) {
return;
}
//将手势设置为PINCH_MODE_FREE将停止后续手势的触发
mPinchMode = PINCH_MODE_FREE;
//停止所有正在进行的动画
cancelAllAnimator();
//如果时间不合法立即执行结果
if (duration <= 0) {
mOuterMatrix.set(endMatrix);
dispatchOuterMatrixChanged();
invalidate();
} else {
//创建矩阵变化动画
mScaleAnimator = new ScaleAnimator(mOuterMatrix, endMatrix, duration);
mScaleAnimator.start();
}
}
/**
* Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
* This method should be called after the camera preview size is determined in
* setUpCameraOutputs and also the size of `mTextureView` is fixed.
*
* @param viewWidth The width of `mTextureView`
* @param viewHeight The height of `mTextureView`
*/
private void configureTransform(final int viewWidth, final int viewHeight) {
final Activity activity = getActivity();
if (null == textureView || null == previewSize || null == activity) {
return;
}
final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
final Matrix matrix = new Matrix();
final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
final RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
final float centerX = viewRect.centerX();
final float centerY = viewRect.centerY();
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
final float scale =
Math.max(
(float) viewHeight / previewSize.getHeight(),
(float) viewWidth / previewSize.getWidth());
matrix.postScale(scale, scale, centerX, centerY);
matrix.postRotate(90 * (rotation - 2), centerX, centerY);
} else if (Surface.ROTATION_180 == rotation) {
matrix.postRotate(180, centerX, centerY);
}
textureView.setTransform(matrix);
}
public void save(int width, int height, boolean transparentBackground, File sigFile) throws IOException {
if (mNotInitialized)
return;
float scale = Math.min((float) width / getWidth(), (float) height / getHeight());
Matrix matrix = new Matrix();
matrix.setScale(scale, scale);
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
canvas.setMatrix(matrix);
int color = transparentBackground ? Color.TRANSPARENT : 0xFFFFFF - mPaint.getColor();
drawSign(canvas, color, mPaint);
if(sigFile.exists() || sigFile.createNewFile()) {
FileOutputStream out = new FileOutputStream(sigFile);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
}
}
/**
* 将图片按照某个角度进行旋转
*
* @param bm 需要旋转的图片
* @param degree 旋转角度
* @return 旋转后的图片
*/
public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
Bitmap returnBm = null;
// 根据旋转角度,生成旋转矩阵
Matrix matrix = new Matrix();
matrix.postRotate(degree);
try {
// 将原始图片按照旋转矩阵进行旋转,并得到新的图片
returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
} catch (OutOfMemoryError e) {
e.printStackTrace();
}
if (returnBm == null) {
returnBm = bm;
}
if (bm != returnBm) {
bm.recycle();
}
return returnBm;
}
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
final ViewParent parent = view.getParent();
if (parent instanceof View && parent != target) {
final View vp = (View) parent;
offsetDescendantMatrix(target, vp, m);
m.preTranslate(-vp.getScrollX(), -vp.getScrollY());
}
m.preTranslate(view.getLeft(), view.getTop());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (!view.getMatrix().isIdentity()) {
m.preConcat(view.getMatrix());
}
}
}
@Override
public void getTransformImpl(
Matrix outTransform,
Rect parentRect,
int childWidth,
int childHeight,
float focusX,
float focusY,
float scaleX,
float scaleY) {
float scale = Math.min(Math.min(scaleX, scaleY), 1.0f);
float dx = parentRect.left;
float dy = parentRect.top;
outTransform.setScale(scale, scale);
outTransform.postTranslate((int) (dx + 0.5f), (int) (dy + 0.5f));
}
@Override
public boolean canScrollHorizontally(int direction) {
matrix.getValues(m);
float x = m[Matrix.MTRANS_X];
if (getImageWidth() < viewWidth) {
return false;
} else if (x >= -1 && direction < 0) {
return false;
} else if (Math.abs(x) + viewWidth + 1 >= getImageWidth() && direction > 0) {
return false;
}
return true;
}
public ContactChipDrawable(int paddingLeft, int paddingRight, Typeface typeface, int textColor, int textSize, int backgroundColor) {
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.FILL);
mPaint.setColor(textColor);
mPaint.setTypeface(typeface);
mPaint.setTextSize(textSize);
mTextPaint = new TextPaint(mPaint);
mMetrics = new BoringLayout.Metrics();
Paint.FontMetricsInt temp = mTextPaint.getFontMetricsInt();
mMetrics.ascent = temp.ascent;
mMetrics.bottom = temp.bottom;
mMetrics.descent = temp.descent;
mMetrics.top = temp.top;
mMetrics.leading = temp.leading;
mRect = new RectF();
mMatrix = new Matrix();
mPaddingLeft = paddingLeft;
mPaddingRight = paddingRight;
mBackgroundColor = backgroundColor;
}
public Transaction setMatrix(SurfaceControl sc, Matrix matrix, float[] float9) {
matrix.getValues(float9);
setMatrix(sc, float9[MSCALE_X], float9[MSKEW_Y],
float9[MSKEW_X], float9[MSCALE_Y]);
setPosition(sc, float9[MTRANS_X], float9[MTRANS_Y]);
return this;
}
/**
* Performs boundary checking and fixes the image matrix if it
* is out of bounds.
*/
private void fixTrans() {
matrix.getValues(m);
float transX = m[Matrix.MTRANS_X];
float transY = m[Matrix.MTRANS_Y];
float fixTransX = getFixTrans(transX, viewWidth, getImageWidth());
float fixTransY = getFixTrans(transY, viewHeight, getImageHeight());
if (fixTransX != 0 || fixTransY != 0) {
matrix.postTranslate(fixTransX, fixTransY);
}
}
/**
* 绘制叶子
*
* @param canvas
*/
private void drawLeafs(Canvas canvas) {
mLeafRotateTime = mLeafRotateTime <= 0 ? LEAF_ROTATE_TIME : mLeafRotateTime;
long currentTime = System.currentTimeMillis();
for (int i = 0; i < mLeafInfos.size(); i++) {
Leaf leaf = mLeafInfos.get(i);
if (currentTime > leaf.startTime && leaf.startTime != 0) {
// 绘制叶子--根据叶子的类型和当前时间得出叶子的(x,y)
getLeafLocation(leaf, currentTime);
// 根据时间计算旋转角度
canvas.save();
// 通过Matrix控制叶子旋转
Matrix matrix = new Matrix();
float transX = mLeftMargin + leaf.x;
float transY = mLeftMargin + leaf.y;
Log.i(TAG, "left.x = " + leaf.x + "--leaf.y=" + leaf.y);
matrix.postTranslate(transX, transY);
// 通过时间关联旋转角度,则可以直接通过修改LEAF_ROTATE_TIME调节叶子旋转快慢
float rotateFraction = ((currentTime - leaf.startTime) % mLeafRotateTime)
/ (float) mLeafRotateTime;
int angle = (int) (rotateFraction * 360);
// 根据叶子旋转方向确定叶子旋转角度
int rotate = leaf.rotateDirection == 0 ? angle + leaf.rotateAngle : -angle
+ leaf.rotateAngle;
matrix.postRotate(rotate, transX
+ mLeafWidth / 2, transY + mLeafHeight / 2);
canvas.drawBitmap(mLeafBitmap, matrix, mBitmapPaint);
canvas.restore();
} else {
continue;
}
}
}
/**
* limits the maximum scale and X translation of the given matrix
*
* @param matrix
*/
public void limitTransAndScale(Matrix matrix, RectF content) {
matrix.getValues(matrixBuffer);
float curTransX = matrixBuffer[Matrix.MTRANS_X];
float curScaleX = matrixBuffer[Matrix.MSCALE_X];
float curTransY = matrixBuffer[Matrix.MTRANS_Y];
float curScaleY = matrixBuffer[Matrix.MSCALE_Y];
// min scale-x is 1f
mScaleX = Math.min(Math.max(mMinScaleX, curScaleX), mMaxScaleX);
// min scale-y is 1f
mScaleY = Math.min(Math.max(mMinScaleY, curScaleY), mMaxScaleY);
float width = 0f;
float height = 0f;
if (content != null) {
width = content.width();
height = content.height();
}
float maxTransX = -width * (mScaleX - 1f);
mTransX = Math.min(Math.max(curTransX, maxTransX - mTransOffsetX), mTransOffsetX);
float maxTransY = height * (mScaleY - 1f);
mTransY = Math.max(Math.min(curTransY, maxTransY + mTransOffsetY), -mTransOffsetY);
matrixBuffer[Matrix.MTRANS_X] = mTransX;
matrixBuffer[Matrix.MSCALE_X] = mScaleX;
matrixBuffer[Matrix.MTRANS_Y] = mTransY;
matrixBuffer[Matrix.MSCALE_Y] = mScaleY;
matrix.setValues(matrixBuffer);
}
public ClippingImageView(Context context) {
super(context);
paint = new Paint();
paint.setFilterBitmap(true);
matrix = new Matrix();
drawRect = new RectF();
bitmapRect = new RectF();
roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
roundRect = new RectF();
shaderMatrix = new Matrix();
}
/**
* After rotating, the matrix needs to be translated. This function finds
* the area of image which was previously centered and adjusts translations
* so that is again the center, post-rotation.
*
* @param axis Matrix.MTRANS_X or Matrix.MTRANS_Y
* @param trans the value of trans in that axis before the rotation
* @param prevImageSize the width/height of the image before the rotation
* @param imageSize width/height of the image after rotation
* @param prevViewSize width/height of view before rotation
* @param viewSize width/height of view after rotation
* @param drawableSize width/height of drawable
*/
private void translateMatrixAfterRotate(int axis, float trans,
float prevImageSize, float imageSize, int prevViewSize,
int viewSize, int drawableSize) {
if (imageSize < viewSize) {
//
// The width/height of image is less than the view's width/height.
// Center it.
//
m[axis] = (viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;
} else if (trans > 0) {
//
// The image is larger than the view, but was not before rotation.
// Center it.
//
m[axis] = -((imageSize - viewSize) * 0.5f);
} else {
//
// Find the area of the image which was previously centered in the
// view. Determine its distance
// from the left/top side of the view as a fraction of the entire
// image's width/height. Use that percentage
// to calculate the trans in the new view width/height.
//
float percentage = (Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
m[axis] = -((percentage * imageSize) - (viewSize * 0.5f));
}
}
/**
* TransformationCallback method
*
* @param transform
*/
@Override
public void getTransform(Matrix transform) {
super.getTransform(transform);
if (mDrawMatrix != null) {
transform.preConcat(mDrawMatrix);
}
}
/**
* Add a new {@link EditorElement} centered in the current visible crop area.
*
* @param element New element to add.
* @param scale Initial scale for new element.
*/
public void addElementCentered(@NonNull EditorElement element, float scale) {
Matrix localMatrix = element.getLocalMatrix();
editorElementHierarchy.getMainImageFullMatrix().invert(localMatrix);
localMatrix.preScale(scale, scale);
addElement(element);
}
public static Bitmap getRotatedBitmap(final File file, final int rotation) {
Bitmap originalBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
final Bitmap rv = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getWidth(), originalBitmap.getHeight(), matrix, true);
if (rv != originalBitmap) {
originalBitmap.recycle();
}
return rv;
}
private void scale() {
if (getDrawable() != null) {
Matrix matrix = getImageMatrix();
float scaleFactor = getWidth()/(float)getDrawable().getIntrinsicWidth();
matrix.setScale(scaleFactor, scaleFactor, 0, 0);
setImageMatrix(matrix);
}
}
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
Bitmap source = resource.get();
int size = Math.min(source.getWidth(), source.getHeight());
int width = (source.getWidth() - size) / 2;
int height = (source.getHeight() - size) / 2;
Bitmap bitmap = mBitmapPool.get(size, size, Bitmap.Config.ARGB_8888);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader =
new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
if (width != 0 || height != 0) {
// source isn't square, move viewport to center
Matrix matrix = new Matrix();
matrix.setTranslate(-width, -height);
shader.setLocalMatrix(matrix);
}
paint.setShader(shader);
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
return BitmapResource.obtain(bitmap, mBitmapPool);
}
/**
* 获得带倒影的图片方法
*
* @param bitmap
* @return
*/
public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap) {
final int reflectionGap = 4;
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Matrix matrix = new Matrix();
matrix.preScale(1, -1);
Bitmap reflectionImage = Bitmap.createBitmap(bitmap, 0, height / 2,
width, height / 2, matrix, false);
Bitmap bitmapWithReflection = Bitmap.createBitmap(width,
(height + height / 2), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmapWithReflection);
canvas.drawBitmap(bitmap, 0, 0, null);
Paint deafalutPaint = new Paint();
canvas.drawRect(0, height, width, height + reflectionGap, deafalutPaint);
canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
Paint paint = new Paint();
LinearGradient shader = new LinearGradient(0, bitmap.getHeight(), 0,
bitmapWithReflection.getHeight() + reflectionGap, 0x70ffffff,
0x00ffffff, TileMode.CLAMP);
paint.setShader(shader);
// Set the Transfer mode to be porter duff and destination in
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
// Draw a rectangle using the paint with our linear gradient
canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
+ reflectionGap, paint);
return bitmapWithReflection;
}
/**
* Sets the zoomable transformation. Cancels the current gesture if one is happening.
*/
public void setTransform(Matrix activeTransform) {
if (mGestureDetector.isGestureInProgress()) {
mGestureDetector.reset();
}
mActiveTransform.set(activeTransform);
}
@Override
public GhostViewImpl addGhost(View view, ViewGroup viewGroup, Matrix matrix) {
GhostViewApi14 ghostView = getGhostView(view);
if (ghostView == null) {
FrameLayout frameLayout = findFrameLayout(viewGroup);
if (frameLayout == null) {
return null;
}
ghostView = new GhostViewApi14(view);
frameLayout.addView(ghostView);
}
ghostView.mReferences++;
return ghostView;
}