android - 如何旋转或缩放ImageView的图像?

标签 android image-scaling image-resizing android-imageview image-rotation

如何使用图像旋转或缩放 ImageView ? Image View 的大小是 Wrap_Content 并且在 Image view 的触摸事件上旋转或缩放图像。

请帮助我。

最佳答案

您可以在 ImageView 上使用 Animation。这是旋转动画的示例:

    Animation anim = new RotateAnimation(0, ANGLE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setDuration(DURATION);
    anim.setRepeatCount(0);
    anim.setFillAfter(true);
    image_view.startAnimation(anim);        

您可以找到缩放和平移动画的类似解决方案。如果您不想看到动画,请将持续时间设置为零。 setFillAfter 很重要,如果您不想在动画后重置图像。祝你好运

关于android - 如何旋转或缩放ImageView的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7334649/

相关文章:

android - React Native Android 不包括一些内置组件和 API

android - 加速 ImageView 中的缩放功能

jquery - 根据浏览器的窗口大小调整边距

android - Apk文件生成-问题

android - 具有多个 View 的 firebase 回收器适配器

Android登录屏幕: Two-way binding EditText and TextView

java - Android 中位图的 inJustDecodeBounds

Android ImageView 将较小的图像缩放到具有灵活高度的宽度,而不会裁剪或扭曲

java - 将图像添加到 JPanel 背景

html - Bootstrap - 屏幕尺寸减小时图像响应