本文整理了Java中android.view.View.getMatrix()
方法的一些代码示例,展示了View.getMatrix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。View.getMatrix()
方法的具体详情如下:
包路径:android.view.View
类名称:View
方法名:getMatrix
暂无
代码示例来源:origin: alexvasilkov/GestureViews
private static void transformMatrixToPager(Matrix matrix, View view, ViewPager pager) {
if (view.getParent() instanceof View) {
View parent = (View) view.getParent();
if (parent != pager) {
transformMatrixToPager(matrix, parent, pager);
}
matrix.preTranslate(-parent.getScrollX(), -parent.getScrollY());
}
matrix.preTranslate(view.getLeft(), view.getTop());
matrix.preConcat(view.getMatrix());
}
代码示例来源:origin: andkulikov/Transitions-Everywhere
private void captureValues(@NonNull TransitionValues transitionValues) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return;
}
View view = transitionValues.view;
if (view.getVisibility() == View.GONE) {
return;
}
transitionValues.values.put(PROPNAME_PARENT, view.getParent());
Transforms transforms = new Transforms(view);
transitionValues.values.put(PROPNAME_TRANSFORMS, transforms);
Matrix matrix = view.getMatrix();
if (matrix == null || matrix.isIdentity()) {
matrix = null;
} else {
matrix = new Matrix(matrix);
}
transitionValues.values.put(PROPNAME_MATRIX, matrix);
if (mReparent) {
Matrix parentMatrix = new Matrix();
ViewGroup parent = (ViewGroup) view.getParent();
ViewUtils.transformMatrixToGlobal(parent, parentMatrix);
parentMatrix.preTranslate(-parent.getScrollX(), -parent.getScrollY());
transitionValues.values.put(PROPNAME_PARENT_MATRIX, parentMatrix);
transitionValues.values.put(PROPNAME_INTERMEDIATE_MATRIX,
view.getTag(R.id.transitionTransform));
transitionValues.values.put(PROPNAME_INTERMEDIATE_PARENT_MATRIX,
view.getTag(R.id.parentMatrix));
}
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
// TODO: why isShown() returns false after being reattached?
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null && !Carbon.IS_PIE_OR_HIGHER)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
public boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
// TODO: why isShown() returns false after being reattached?
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
// TODO: why isShown() returns false after being reattached?
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
// TODO: why isShown() returns false after being reattached?
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: ZieIony/Carbon
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
// TODO: why isShown() returns false after being reattached?
if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) {
ShadowView shadowView = (ShadowView) child;
shadowView.drawShadow(canvas);
}
if (child instanceof RippleView) {
RippleView rippleView = (RippleView) child;
RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
int saveCount = canvas.save();
canvas.translate(child.getLeft(), child.getTop());
canvas.concat(child.getMatrix());
rippleDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
}
return super.drawChild(canvas, child, drawingTime);
}
代码示例来源:origin: burhanrashid52/PhotoEditor
private static void adjustTranslation(View view, float deltaX, float deltaY) {
float[] deltaVector = {deltaX, deltaY};
view.getMatrix().mapVectors(deltaVector);
view.setTranslationX(view.getTranslationX() + deltaVector[0]);
view.setTranslationY(view.getTranslationY() + deltaVector[1]);
}
代码示例来源:origin: bufferapp/BufferTextInputLayout
private 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 (!view.getMatrix().isIdentity()) {
m.preConcat(view.getMatrix());
}
}
}
代码示例来源:origin: burhanrashid52/PhotoEditor
private static void computeRenderOffset(View view, float pivotX, float pivotY) {
if (view.getPivotX() == pivotX && view.getPivotY() == pivotY) {
return;
}
float[] prevPoint = {0.0f, 0.0f};
view.getMatrix().mapPoints(prevPoint);
view.setPivotX(pivotX);
view.setPivotY(pivotY);
float[] currPoint = {0.0f, 0.0f};
view.getMatrix().mapPoints(currPoint);
float offsetX = currPoint[0] - prevPoint[0];
float offsetY = currPoint[1] - prevPoint[1];
view.setTranslationX(view.getTranslationX() - offsetX);
view.setTranslationY(view.getTranslationY() - offsetY);
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
private float[] mapPointFromParentToView(View v, float x, float y) {
sTmpPoint[0] = x - v.getLeft();
sTmpPoint[1] = y - v.getTop();
v.getMatrix().invert(sTmpInvMatrix);
sTmpInvMatrix.mapPoints(sTmpPoint);
return sTmpPoint;
}
代码示例来源:origin: enricocid/LaunchEnr
private float[] mapPointFromParentToView(View v, float x, float y) {
sTmpPoint[0] = x - v.getLeft();
sTmpPoint[1] = y - v.getTop();
v.getMatrix().invert(sTmpInvMatrix);
sTmpInvMatrix.mapPoints(sTmpPoint);
return sTmpPoint;
}
代码示例来源:origin: klinker24/launcher3
private float[] mapPointFromParentToView(View v, float x, float y) {
sTmpPoint[0] = x - v.getLeft();
sTmpPoint[1] = y - v.getTop();
v.getMatrix().invert(sTmpInvMatrix);
sTmpInvMatrix.mapPoints(sTmpPoint);
return sTmpPoint;
}
内容来源于网络,如有侵权,请联系作者删除!