Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I align an image inside an ImageView to the bottom of the ImageView?

I want the drawable inside my ImageView to be shown aligned to the bottom (of the Imageview), and not centered.

Is it possible to do that?

like image 340
Ivan Avatar asked Aug 31 '11 11:08

Ivan


People also ask

Which method from the ImageView class allows you to adjust the transparency of an image?

Set transparency using setAlpha(float alpha) .

Which attribute is used to set an image in ImageView?

src: src is an attribute used to set a source file or you can say image in your imageview to make your layout attractive.

What is difference between ImageView and ImageButton?

ImageButton has the same property as ImageView . Only one feature is extra, which is, images set through ImageButton are clickable, and actions can be attached with them upon clicking. Just like a button, the setOnClickListener() can be used to set an event listener for click event on this.


1 Answers

Maybe this is too late, but even I ran into the same problem today and fixed it by using the following snippet.

All the alignment/scaling options are in the scaleType attribute.

Now, if you want to align the image with the beginning of the ImageView, use android:scaleType="fitStart".

Similarly, android:scaleType="fitEnd" to align it with the bottom of the ImageView.

like image 71
Swayam Avatar answered Sep 21 '22 05:09

Swayam