ImageView setScaleType not working

后端 未结 2 500
感动是毒
感动是毒 2020-12-22 00:29

I have an ImageView and I want to to scale CENTER_CROP. If I set the image src and scale type in XML it works great. But I need to set the image in code. The fo

相关标签:
2条回答
  • 2020-12-22 00:50

    and not forget that your ImageView must be NOT:

     android:layout_width="wrap_content"
         android:layout_height="wrap_content"
    

    but ONLY:

     android:layout_width="match_parent"
         android:layout_height="match_parent"
    

    for proper transformation

    0 讨论(0)
  • 2020-12-22 01:13

    setBackgroundResource sets imageView's background so it is normal behaviour that stretches...

    Use setImageResource instead, it will set imageview's source so it will follow your scaleType definition.

    0 讨论(0)
提交回复
热议问题