ScaleType attribute usage analysis of ImageView in Android development _android

Source: Internet
Author: User
Tags sqlite database

The example in this article describes the ScaleType attribute usage of ImageView in Android development. Share to everyone for your reference, specific as follows:

The ImageView property Android:scaletype, that is, Imageview.setscaletype (Imageview.scaletype). Android:scaletype is the size that controls how the picture resized/moved to the ImageView. Meaning difference of Imageview.scaletype/android:scaletype value:

Center/center is centered by the original size of the picture, and the center portion of the picture is displayed when the picture is longer/wider than the view's length/width.

Center_crop/centercrop proportionally enlarge the size of the picture to be centered so that the picture is long (wide) equal to or greater than the view's length (width)

Center_inside/centerinside the contents of the picture to the full center, by scaling or the original size so that the picture length/width is equal to or less than the view's length/width

Fit_center/fitcenter enlarge/Shrink the picture to the width of view, centered

Fit_end/fitend expands/shrinks the picture to the width of the view, displayed in the lower part of the view

Fit_start/fitstart expands/shrinks the picture to the width of the view, displayed in the upper part of the view

FIT_XY/FITXY enlarge/Reduce picture to view size display

Matrix/matrix using matrices to draw

I didn't understand it at first. Matrix matrices, online search after found that the matrix can be dynamically reduced to enlarge the image of the picture to show, here do not expand in-depth understanding, just paste the relevant statements, reduce the picture:

Obtain bitmap of high and wide
int bmpwidth=bmp.getwidth ();
int bmpheight=bmp.getheight ();
Set narrowing ratio
double scale=0.8;
Calculate the proportion to be reduced
scalewidth= (float) (Scalewidth*scale);
scaleheight= (float) (Scaleheight*scale);
Matrix
matrix=new Matrix () of the bitmap object after producing resize;
Matrix.postscale (ScaleWidth, scaleheight);
Bitmap resizebmp=bitmap.createbitmap (BMP, 0, 0, bmpwidth, Bmpheight, Matrix, True);

For more information on Android-related content readers can view the site: "Android graphics and image processing skills summary", "Android photography and image processing skills summary", "Android programming activity Operation Skills Summary", " Android View tips Summary, Android operations SQLite database tips, "Android operation JSON data skills summary", "Android Database Operating skills summary", "Android File Operating skills summary", " Android programming development of the SD card operation method Summary, "Android Development introduction and Advanced Course", "Android Resource Operation skills Summary" and "Android Control usage Summary"

I hope this article will help you with the Android program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.