![]() ![]() I needed to get this done in a constraint layout with Picasso, so I munged together some of the above answers and came up with this solution (I already know the aspect ratio of the image I'm loading, so that helps):Ĭalled in my activity code somewhere after setContentView(. * adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width * maximum of 100 x 100 while preserving the original aspect ratio, do the following: 1) set :) private void scaleImage(ImageView view) throws NoSuchElementException has been set to true. I tested it via button click handler.Įnjoy. Then the ImageView is resized to match the dimensions of the scaled image. This code scales Drawable of an ImageView to stay in a square like 250dp x 250dp with one dimension exactly 250dp and keeping the aspect ratio. Still, they often result in poor quality thumbnail generation and lacks the necessary configuration you need to control the compression & quality. ![]() You can rely on platforms inbuilt image scaling options. It is not possible to scale both the image and the ImageView so that image's one dimension would always be 250dp and the ImageView would have the same dimensions as the image. Manually resizing images is not an option if you have more than a hundred assets on your websites. (The answer was heavily modified after clarifications to the original question) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |