Before using the glide was ImageView picture settings confused (very low-level problem, it is often a problem), so went to see the ImageView, fill the foundation.
First, ImageView has two properties that show the picture, SRC and background respectively. From the name, you can know that the first is the resource (painting), the second is the background (frame).
How do you set these two values?
Background
mimageview.setbackground ();
Mimageview.setbackgroundresource ();
Mimageview.setbackgroundcolor ();
Mimageview.setbackgrounddrawable ();
SRC
mimageview.setimageresource ();
Mimageview.setimagedrawable ();
Mimageview.setimageuri ();
Of the 4 methods that set up background, the setbackgrounddrawable () of the @deprecated method is ultimately called.
Some differences:
1.SRC is the size of the original image, background will be stretched according to the size of the component.
2.SRC is the content of the picture (painting), background is the background of the picture (frame), can exist at the same time.
3.background can set the transparency, SRC cannot be.
4.scaleType only works on SRC. This text explains very clearly->scaletype detailed explanation
5. Use setbackgrounddrawable when drawing in custom ImageView. If use setimagedrawable, need to set setintrinsicheight and setintrinsicwidth, otherwise will not show, specific reason to see the source code bar.
Through this article hope to help to have the need of small partners, thank you for your support to this site!