Android UI之ImageView旋转的几种方式
来源:互联网 发布:软件导刊 核心期刊 编辑:程序博客网 时间:2024/04/30 14:18
我整理了一下,大概有四种,亲测成功三种。
第一种,效率较低,不过看许多博客都使用这种方法,即旋转bitmap:
Bitmap bitmap = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_launcher)).getBitmap();Matrix matrix = new Matrix();matrix.setRotate(90);Bitmap new = Bitmap.create(bitmap,0,bitmap.getWidth(),0,bitmap.getHeight(),matrix);image.setBitmapResource(bitmap);
如果程序不断获取新的bitmap重新设置给ImageView的话,那么bitmap在不断旋转,又不回收内存,浪费大大哒,不推荐使用。
第二种,使用ImageView自带的旋转方法
可以通过在xml中设置ImageView的属性来实现,如
android:rotation="90",这样。
动态调用如下:
image.setPivotX(image.getWidth()/2);image.setPivotY(image.getHeight()/2);//支点在图片中心image.setRotation(90);
第三种,使用旋转动画
第四种,其他博客看到的,未测试!
Matrix matrix=new Matrix(); rotateImage.setScaleType(ScaleType.MATRIX); //required matrix.postRotate((float) progress, pivotX, pivotY); rotateImage.setImageMatrix(matrix);
0 0
- Android UI之ImageView旋转的几种方式
- imageview旋转的几种方式
- Android之ImageView的加边框颜色的几种实现方式
- Android 更新UI的几种方式
- Android更新UI的几种方式
- Android 更新UI的几种方式
- Android 更新UI的几种方式
- 关于Android圆角ImageView的几种实现方式
- Android UI之ImageView
- Android--UI之ImageView
- Android: 在UI线程更新UI的几种方式
- ImageView加载图片的几种方式
- ImageView设置图片的几种方式
- 【Android UI】Android开发之View的几种布局方式及实践
- Android UI 详解之ImageView
- android刷新UI的几种方式总结
- 【UI布局优化】Android布局优化的几种方式
- Android中更新UI的几种方式
- pylint消息输出集
- 第一课: 通过案例对SparkStreaming透彻理解三板斧之二
- 默认形参只能放在声明中, 不能放在定义中------今天碰到了, 耗费3分钟才fix 编译 error!
- 布局相关
- 继承优于标签
- Android UI之ImageView旋转的几种方式
- 多维偏好分析
- 【剑指offer】面试题13:在O(1)时间删除出链表结点
- phptrace 的使用
- 如何找到占用端口的进程并关闭
- 2016的封闭开发
- Keywords Search hdu2222 ac自动机
- 《剑指Offer》面试题四之替换空格
- JVM垃圾收集算法