Android图片旋转
来源:互联网 发布:国学大师txt数据库 编辑:程序博客网 时间:2024/05/17 23:55
Android中,我们可以使用矩阵实现图像旋转
首先,创建一个布局xml文件:
- <?xml version="1.0" encoding="utf-8"?><br />
- <LinearLayout android:id="@+id/LinearLayout01"<br />
- android:layout_width="fill_parent"<br />
- android:layout_height="fill_parent"<br />
- xmlns:android="http://schemas.android.com/apk/res/android"<br />
- android:background="#ffffff"<br />
- android:gravity="center"><br />
- <ImageView android:id="@+id/ImageView01"<br />
- android:layout_width="wrap_content"<br />
- android:layout_height="wrap_content"<br />
- android:src="@drawable/refresh" /><br />
- </LinearLayout><br />
创建主Activity类文件:
- public class ExampleApp extends Activity
- {
- private ImageView img;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- img=(ImageView)findViewById(R.id.ImageView01);
- Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.refresh);
- // Getting width & height of the given image.
- int w = bmp.getWidth();
- int h = bmp.getHeight();
- // Setting post rotate to 90
- Matrix mtx = new Matrix();
- mtx.postRotate(90);
- // Rotating Bitmap
- Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
- BitmapDrawable bmd = new BitmapDrawable(rotatedBMP);
- img.setImageDrawable(bmd);
- }
- }
0 0
- Android图片旋转
- android 图片旋转
- android旋转图片
- android图片旋转处理
- android 图片旋转
- android 图片旋转
- Android 图片旋转问题
- Android 图片旋转
- android 图片旋转
- Android 旋转图片
- Android图片与旋转
- Android图片与旋转
- Android图片旋转
- Android之图片旋转
- Android旋转图片
- Android 图片上下旋转
- Android 图片旋转 动画
- Android 不停旋转图片
- fill_parent、wrap_content和match_parent的区别
- iOS 代码实践总结
- 高性能mysql(一)优化数据类型
- 小强的HTML5移动开发之路(17)——HTML5内联SVG
- ios- 死锁
- Android图片旋转
- 进入实战,开发酷欧天气(一)
- office2010 word 关闭很慢
- Win10家庭版升级至专业版
- HDU5361 In Touch
- .net 简单易懂的扩展方法教程
- phpcms v9 数据库操作函数
- 字符串进行运算
- jquery获取元素大全