Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions?

前端 未结 17 1034
无人共我
无人共我 2020-11-22 17:07

How to fit an image of random size to an ImageView?
When:

  • Initially ImageView dimensions are 250dp * 250dp
  • The image\'
17条回答
  •  无人及你
    2020-11-22 17:27

    After searching for a day, I think this is the easiest solution:

    imageView.getLayoutParams().width = 250;
    imageView.getLayoutParams().height = 250;
    imageView.setAdjustViewBounds(true);
    

提交回复
热议问题