我从字节数组创建了一个位图图像,并在ImageView中显示它。ImageView的android:layout_width和android:layout_height被设置为wrap_content,android:scaleType被设置为center。但是这张图片仍然会按比例缩放到屏幕大小。
有没有一种方法可以以原始尺寸显示图像(就像直接使用android:src属性一样)?
代码:
从字节数组创建位图:
有没有一种方法可以以原始尺寸显示图像(就像直接使用android:src属性一样)?
代码:
从字节数组创建位图:
private Bitmap decodeBitmap(byte[] data) {
return BitmapFactory.decodeByteArray(data, 0, data.length);
}
和ImageView的布局:
<ImageView
android:id="@+id/logo"
android:scaleType="centerInside"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
将图像设置为ImageView:
mView.setImageBitmap(mBitmap);