Reputation: 6912
I have an ImageView.
I set it in xml as below:
<ImageView
android:id="@+id/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
And set image as below:
ImageView background
background.setImageBitmap(bitmap);
But if the ImageView's parent layout narrow down, the IamgeView also narrow down.
And the image was resized.
I want to let it don't resize.
Is it can modify by setScaleType?
Or how to do it?
Upvotes: 0
Views: 4561
Reputation: 69228
Try setting adjustViewBounds parameter to true on the ImageView.
<ImageView
android:id="@+id/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"/>
Upvotes: 9
Reputation: 5803
Why don't you use scaledBitmap
like this
Bitmap bMap = Bitmap.createScaledBitmap(chosenBitmap, needed_width, needed_height, true);
imageView.setImageBitmap(bMap);
Upvotes: 3