Waza_Be
Waza_Be

Reputation: 39538

CENTER_CROP does not maintain image ratio

By reading the Android doc, I expect a picture with this layout:

<ImageView
    android:id="@+id/avatar"
    android:layout_width="fill_parent"
    android:layout_height="150dip"
    android:adjustViewBounds="true"
    android:scaleType="centerCrop" />

to fill the layout (height of 150 dip is the only condition) without any distorsion:

CENTER_CROP Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).

That works pretty well on phones:

enter image description here

But on tablet the image is totally distorted:

enter image description here

How is that possible to say: "please do not stretch horizontally"

Upvotes: 2

Views: 1212

Answers (1)

WindyB
WindyB

Reputation: 786

I think you're specifying the image as a background rather than as a source. The images look stretched on the phone as well, and CenterCrop should work fine.

Try using the setImageBitmap or the "src" attribute and let me know if it works.

Upvotes: 5

Related Questions