Imageview shows that the picture is nothing more than one is to load a local image, but to load a network image.
One
,
load
a
local image
4. When using android:scaleType, it is necessary to set src, and setting background does not work. Generally, if the image is loaded from the network, the default is src, so when setting android:scaleType, if you want to display in full screen, please correspond to your own needs. The type of
CENTER /center
is displayed in the center according to the original size of the image. When the length/width of the image exceeds the length/width of the View, the center part of the intercepted image will be displayed. Equal to or greater than the length (width) of the View**
FIT_CENTER / fitCenter expands/reduces the image to the width of the View proportionally, and displays it in the center
FIT_END / fitEnd expands/reduces the image to the width of the View proportionally, and displays it in the lower part of the View
FIT_START / fitStart expands/reduces the picture to the width of the View proportionally, and displays it in the upper part of the View
FIT_XY / fitXY expands/reduces the picture to the size of the View without proportionality Display MATRIX / matrix is drawn with a matrix, and the picture is dynamically reduced and enlarged to display.
If it is a network request image, you can also not set android:scaleType. Just need to set it in glide.
2. Loading network pictures
This requirement is quite painful for me. I am using Gilde to load pictures. When I set android:scaleType according to Imageview, either the image is cropped and displayed all, or all is displayed but not filled. After that, I wondered if it was not a layout problem, it would be a problem with the use of gilde.
Glide.with(getActivity())
.load(GlobalParam.IP + data.getImage())
.centerCrop()//会裁减图片填充布局
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.mipmap.upload_image_side)
.error(R.mipmap.upload_image_side)
.into(imageView);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
Later, I discovered the .fitCenter() method, which has the same effect as setting the image size locally. Perfectly solve the problem of incomplete picture display,
hereby record it. . . . . .