Article source: blog.sina.com.cn/s/blog_6181…
AdjustViewBounds =”true” (adjustViewBounds)
android:id=”@+id/dynamic_item_image”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_gravity=”top”
android:layout_marginTop=”5dip”
android:adjustViewBounds=”true”
Android :background=”@drawable/imageview_background” /> The imageview_background. XML:
< shape * * XMLNS: android = “schemas.android.com/apk/res/and… Android: color = “@ color/white” / > < stroke android: width = “2.0 dip” android: color = “# 99 d9d9d9” / > < cornersandroid: the radius = “2.0 dip” Paddingandroid :left=”5.0dip” android:top=”5.0dip” Android :right=”5.0dip” Android :bottom=”5.0dip” /> ImageView attribute description: \
1, Class overview \
Displays arbitrary images, such as ICONS. The ImageView class can load images from a variety of sources (such as resources or photo libraries), calculate the size of the image so that it can be used in other layouts, and provide various display options such as scaling and coloring (rendering).
2. XML attributes
The attribute name | describe | ||
---|---|---|---|
android:adjustViewBounds | Whether to maintain the aspect ratio. It must be used with maxWidth and MaxHeight, otherwise it will not work alone. | ||
android:cropToPadding | Whether to intercept the specified area and replace it with white space. Setting alone has no effect. It needs to be used together with scrollY. The effect is as follows.ImageView图片自适应”> | ||
android:maxHeight | Set the maximum height of the View, this doesn’t work alone, need to be used with setAdjustViewBounds. Set setAdjustViewBounds to True if you want to set the adjustBounds to fixed size. 2) Set maxWidth and MaxHeight; 3) Set layout_width and layout_height to wrap_content. | ||
android:maxWidth | Set the maximum View width. Same as above. | ||
android:scaleType | Sets how to fill the image. | matrix | 0 |
———— | – | ———————————————————————————————————————— ——————————————- | —————————————————– |
fitXY | 1 | Stretch the image (out of scale) to fill in the width and height of the ViewImageView图片自适应”> | layout_height:30pxlayout_width:120px |
fitStart | 2 | Stretch the image in proportion to the height of the View and display it on the left side of the ViewImageView图片自适应”> | |
fitCenter | 3 | Stretch the image in proportion to the height of the View and display it in the middle of the ViewImageView图片自适应”> | |
fitEnd | 4 | Stretch the image in proportion to the height of the View and display it on the right side of the ViewImageView图片自适应”> | |
center | 5 | If the size of the original image is displayed but the width of the image is larger than that of the View, the middle part of the screenshot will be displayedImageView图片自适应”> | layout_height:60pxlayout_width:80pxpadding:10px |
centerCrop | 6 | Scale up the original image until it is equal to the width and height of a View.ImageView图片自适应”> | |
centerInside | 7 | When the width and height of the original image is equal to the width and height of View, it will be displayed in the center according to the size of the original image; Instead, zoom the original image to the width of the View.ImageView图片自适应”> | |
android:src | Set the View’s drawable(for example, a picture, or a color, but you need to specify the size of the View) | ||
android:tint | Renders the image to the specified color. See below:ImageView图片自适应”>The left is the original image, and the right is the effect after setting, as shown in the following code. |
\