Mau*_*k.J 7 android android-imageview
我正在开发一个应用程序,我需要ImageView触摸触摸并将控制转移到第二个活动.
请帮我.
我尝试了很多,但我没有成功.
谢谢大家.
您不需要使用任何库,您可以尝试以下简单的功能来水平或垂直翻转图像视图,
final static int FLIP_VERTICAL = 1;
final static int FLIP_HORIZONTAL = 2;
public static Bitmap flip(Bitmap src, int type) {
// create new matrix for transformation
Matrix matrix = new Matrix();
// if vertical
if(type == FLIP_VERTICAL) {
matrix.preScale(1.0f, -1.0f);
}
// if horizonal
else if(type == FLIP_HORIZONTAL) {
matrix.preScale(-1.0f, 1.0f);
// unknown type
} else {
return null;
}
// return transformed image
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}
Run Code Online (Sandbox Code Playgroud)
您必须传递与要翻转的图像视图相关联的位图和翻转类型。例如,
ImageView myImageView = (ImageView) findViewById(R.id.myImageView);
Bitmap bitmap = ((BitmapDrawable)myImageView.getDrawable()).getBitmap(); // get bitmap associated with your imageview
myImageView .setImageBitmap(flip(bitmap ,FLIP_HORIZONTAL));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15468 次 |
| 最近记录: |