Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ImageView how to fit left-bottom such as setScaleType(ScaleType.FIT_END);, but not fit right-bottom

I use below code to set ImageView's ScaleType:

iv.setScaleType(ScaleType.FIT_END);

It will fit right-bottom.
But I want to make picture fit left-bottom.
How can I do it?

like image 533
brian Avatar asked Dec 26 '22 00:12

brian


2 Answers

Try setting the imageview's adjust view bound to true and then set the align bottom parent and align left parent to true. hope that works :)

like image 99
Deepak Senapati Avatar answered Apr 06 '23 15:04

Deepak Senapati


Another solution:

imageView.setAdjustViewBounds(true);
imageView.setBaselineAlignBottom(true);

Works for API_LEVEL >= 11.

like image 43
eleven Avatar answered Apr 06 '23 14:04

eleven