列出 android Matrix 的api 列表和如何使用
Android Matrix API 列表:
- setTranslate(float dx, float dy):设置矩阵平移的值
- setScale(float sx, float sy):设置矩阵缩放的值
- setRotate(float degrees):设置矩阵旋转的角度
- setSkew(float kx, float ky):设置矩阵倾斜的值
- setConcat(Matrix a, Matrix b):将两个矩阵进行合并
- preTranslate(float dx, float dy):在矩阵平移之前进行预平移
- preScale(float sx, float sy):在矩阵缩放之前进行预缩放
- preRotate(float degrees):在矩阵旋转之前进行预旋转
- preSkew(float kx, float ky):在矩阵倾斜之前进行预倾斜
- postTranslate(float dx, float dy):在矩阵平移之后进行后平移
- postScale(float sx, float sy):在矩阵缩放之后进行后缩放
- postRotate(float degrees):在矩阵旋转之后进行后旋转
- postSkew(float kx, float ky):在矩阵倾斜之后进行后倾斜
- mapPoints(float[] dst, float[] src):将源点映射到目标点
- mapRect(RectF dst, RectF src):将源矩形映射到目标矩形
使用方法:
- 创建一个 Matrix 对象:Matrix matrix = new Matrix();
- 调用 Matrix 对象的 API 进行矩阵变换,例如:matrix.setTranslate(100, 200);
- 将变换应用到 View 上,例如:view.setImageMatrix(matrix)
原文地址: http://www.cveoy.top/t/topic/eH1b 著作权归作者所有。请勿转载和采集!