ImageView 组件可用于显示Android 系统支持的图像 gif 、jpg、png、bmp等。在xml 布局文件中使用<ImageView> 标签来定义一个ImageView组件,代码如下:
<ImageView android:id="@+id/imageview" android:layout_width="wrap_content"
android:backgroud="#F00" android:layout_height="wrap_content"
android:src=“@drawable/icon” android:scaleType="center" />
在上面的代码中通过android:src 属性指定了一个drawable资源的ID,并使用android:scaleType属性指定ImageView组件显示图像的方式。例如,center表示将图像以不
缩放的方式显示在Imageview组件中心。如果将android:scaleType属性设为fitCenter,表示将图像按比例缩放至合适的位置,并显示在ImageView组件的中心。通过在设计相框时将android:scaleType 属性设为fitCenter,这样可以将照片按比例显示在相框的中心。