Ivo
Ivo

Reputation: 23154

Align image in image view right and center vertical

Let's say i have an ImageView with this aspect ratio

#####
#####
#####

I want to be able to fit images in it that can have different aspect ratios.

If an Image has this ratio

00
00
00

I want it to be

###00
###00
###00

So android:scaleType="fitEnd" would work

But if I have an image with a ratio of

00000

I want it to be

#####
00000
#####

so here android:scaleType="fitCenter" is needed.

Is there a way to combine this?

Upvotes: 4

Views: 1998

Answers (1)

Sergi Juanola
Sergi Juanola

Reputation: 6647

You can't use two scaleTypes in the same attribute. You may need to wait for the image to be loaded and then decide what scaleType use with imgView.setScaleType(ImageView.ScaleType.CENTER) or so.

Upvotes: 1

Related Questions