繁体   English   中英

在图像视图中显示全尺寸网格图像是模糊的

[英]Showing fullsize grid image in image view is blurry

我有一个从相机拍摄或从画廊拍摄的查看照片网格。 当我单击网格视图项目以使其在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使图像看起来模糊。 但是,如果我给出宽度和高度的具体数字,它看起来会更小或实际上是巨大的,但不是正确的尺寸,因为它的清晰程度与在相机中单击或在画廊中选择的尺寸完全相同。 如何将其恢复到正确的大小。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM