[Android] Image zoom

Source: Internet
Author: User

interface layout, linear layout, vertical arrangement, two x ImageView

Get to two ImageView Objects

Call the Bitmapfactory.decoderesource (res,id) method to get the Bitmap Object

Parameters:res is getresource (),ID is resource ID such as: r.drawable.xxx

Call the ImageView object's setimageviewbitmap (), parameter:Bitmap Object

Get an editable Bitmap Object

Call the createbitmap (width,height,config) method of the Bitmap object to get an editable Bitmap Object

Parameters: Wide Height configuration, these are the original width height,Bitmap object getwidth (),getheight (), GetConfig ()

Get the canvas object, via new canvas (bitmap), Parameters:bitmap Object

Call the drawbitmap (bitmap,matrix,paint) method of the Canvas object,

Parameters:Bitmap object template, matrix is a fabric,paint is a brush

Get the Paint object, come out with new

Call the SetColor () method of the paint object , set the brush color, parameters:color.black

Get the Matrix object and come out with new

Call the setValue (value) method of the Matrix object to set the matrix value

Parameter:value is float[] Array,(0.5f,0,0,0,1,0,0,0,1)

This matrix is not clear to most people, so there is another API

Call the Matrix object's setscale (sx,sy), set the scale, parameter: Half is 0.5f 0.5f

Call the Setimagebitmap () method of the second ImageView object to show

[Android] Image zoom

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.