我有从相机拍摄或从画廊拍摄的视图图片网格。当我单击网格视图项以使其在imageview活动中显示全尺寸图像时,图像模糊。
这就是我的网格看起来的样子
<GridView
android:id ="@+id/grid_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:columnWidth="80dp"
android:horizontalSpacing="10dp"
android:verticalSpacing="1dp"
android:gravity="center"
android:stretchMode="columnWidth"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:background="#FFFFFF"/>
将数据提供给网格的Adapter类getView()看起来像这样
public View getView(int position, View convertView, ViewGroup parent) {
//create new image view to show the thumbnail
ImageView imageView = new ImageView(mContext); //create a new imageview in the context thats passed (ie., mainView)
Contact picture = data.get(position);
byte[] img = picture._image; //get the bytes out of Contact
ByteArrayInputStream imgStream = new ByteArrayInputStream(img);
Bitmap theImage = BitmapFactory.decodeStream(imgStream);
imageView.setImageBitmap(theImage);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(200,200));
return imageView;
}
以全尺寸显示图像的活动具有以下xml
<LinearLayout
android:id="@+id/linear"
android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button
android:id="@+id/delete"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:text="Delete"
android:layout_weight="50"/>
<Button
android:id="@+id/share"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:text="Share"
android:layout_weight="50"/>
</LinearLayout>
<ImageView
android:id="@+id/fullimageView"
android:src="@drawable/facebook"
android:adjustViewBounds="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
我相信fill_parent使图像看起来模糊。但是,如果我给出宽度和高度的具体数字,它看起来更小或非常大,但不是正确的尺寸,其清晰,与在相机中点击或在图库中选择的完全相同。如何将其恢复到正确的大小。