开发者

ImageView padding above and below image

开发者 https://www.devze.com 2023-03-01 09:05 出处:网络
I am trying to set the image of an ImageView from a byte array like this: Bitmap bitmap = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);

I am trying to set the image of an ImageView from a byte array like this:

Bitmap bitmap = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
ImageView imageView = (ImageView)findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);

But the image appears to have some quite large black padding at the top and the开发者_如何学Python bottom, even though the actual image data does not have these. The ImageView is at the top of a LinearLayout inside a ScrollView, any ideas?

My ImageView is designed like this:

<ImageView android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/imageView"/>


Solved, I added

android:adjustViewBounds="true"

Into the XML file.

0

精彩评论

暂无评论...
验证码 换一张
取 消