カメラからキャプチャした、またはギャラリーから撮影したビューの写真のグリッドがあります。グリッド ビュー アイテムをクリックして、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"/>
データをグリッドにフィードするアダプタ クラス 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 を使用すると、画像がぼやけて見えると思います。しかし、幅と高さに特定の数値を与えると、小さくまたは非常に大きく見えますが、カメラでクリックされたものやギャラリーで選択されたものと正確に同じである適切な寸法ではありません. 正しいサイズに戻す方法。