ImageView实现对图片的缩放和旋转
一种简单的方法是改变控件ImageView控件的大小,我们只要将ImageView标签中的 android:scaleType的属性值设置为fitCenter,要是想实现图像的旋转可以使用android.graphics.Matrix类的setRotate来实现
下面是一个案例的代码
布局文件代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- 设置图片的显示方式:把图片按比例扩大或者缩小到view的宽度 -->
<ImageView
android:id="@+id/iv_pic"
android:layout_width="match_parent"
android:layout_height="300dip"
android:scaleType="fitCenter"
android:src="@drawable/ying"