如何在Android中翻转ImageView?

如何在Android中翻转ImageView?,android,android-imageview,Android,Android Imageview,我正在开发一个应用程序,需要在触摸时翻转ImageView,并将控制转移到第二个活动 请帮帮我 我试了很多,但没有成功 提前感谢大家。您可以使用适用于Android 3.0及以上版本的动画API 如果您需要它,可以使用名为的库 查看要使用的确切代码。这里有一个很好的翻转图像库: 您不需要使用任何库,您可以尝试以下简单功能水平或垂直翻转imageview final static int FLIP_VERTICAL = 1; final static int FLIP_HORIZO

我正在开发一个应用程序,需要在触摸时翻转
ImageView
,并将控制转移到第二个活动

请帮帮我

我试了很多,但没有成功


提前感谢大家。

您可以使用适用于Android 3.0及以上版本的动画API

如果您需要它,可以使用名为的库


查看要使用的确切代码。

这里有一个很好的翻转图像库:


您不需要使用任何库,您可以尝试以下简单功能水平或垂直翻转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);
        }
您必须传递与要翻转的imageview关联的位图和翻转类型。比如说,

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));

试了很多,你试过什么?张贴在这里。