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.![]() |
||
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 View |
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 View |
|
fitCenter | 3 | Stretch the image in proportion to the height of the View and display it in the middle of the View |
|
fitEnd | 4 | Stretch the image in proportion to the height of the View and display it on the right side of the View |
|
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 displayed |
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. |
|
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. |
|
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:![]() |
\