Reputation: 813
I have an ImageView with the size of 70dp width and height. Its for my ListView and contains an image src of 800x800.
My Problem now is that this picture is so huge that it looks too sharp in my ImageView. How can I prevent this ?
<ImageView
android:id="@+id/imageView_albumart"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginRight="5dp"
android:src="@drawable/cd_800x800" />
Upvotes: 1
Views: 2732
Reputation: 6663
Actually you can play with your Bitmap. Rotate, compress ,convert other formats etc.. We decrease quality 100 to 25 in below code.
So this is code :
Bitmap oldbitmap=Bitmap bitmap = ((BitmapDrawable)yourimageview.getDrawable()).getBitmap();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
oldbitmap.compress(Bitmap.CompressFormat.JPEG, 25,baos);
Bitmap newbitmap=BitmapFactory.decodeStream(new ByteArrayInputStream(baos.toByteArray()));
yourimageview.setImageBitmap(newbitmap);
Upvotes: 2