private Matrix matrix;
public void scale(View view) {
float s = Float.parseFloat(scale.getText().toString());
matrix.postScale(s, s);
//将 matrix 设置到 imageView
img.setImageMatrix(matrix);
}
public void rotate(View view) {
float degree = Float.parseFloat(rotate.getText().toString());
matrix.postRotate(degree);
img.setImageMatrix(matrix);
}
public void translate(View view) {
float dx = Float.parseFloat(translate.getText().toString());
float dy = Float.parseFloat(back.getText().toString());
//保存平移数据
matrix.postTranslate(dx, dy);
img.setImageMatrix(matrix);
}
public void back(View view) {
matrix.reset();
img.setImageMatrix(matrix);
}
Android 通过Matrix来对图片进行缩放,旋转和平移
最新推荐文章于 2021-05-27 05:31:44 发布
2859

被折叠的 条评论
为什么被折叠?



