Study on the vectordrawable of androidの vector graphics

Source: Internet
Author: User

More than 5.0 support vectordrawable, you can create the vector XML resource file. Vectors are actually used to draw vector graphics.

See an example:

<?XML version= "1.0" encoding= "Utf-8"?><Vectorxmlns:android= "Http://schemas.android.com/apk/res/android"Android:height= "64DP"Android:width= "64DP"Android:viewportheight= "+"Android:viewportwidth= "+">        <PathAndroid:fillcolor= "#000000"Android:pathdata= "m25,0 l 50,50-50,50z"/></Vector>

First the vector tag is a drawable object, so it is placed in the Res/drawable directory.

The vector tag has the android:width and Android:height properties, both of which are required to define the absolute size of the vector graphics, although the vector graphics are arbitrarily scaled, but it cannot be said that this does not define the width height directly to the width height of the control defined on the target control to be set to, This is not allowed, be sure to set this absolute width, or else will error.

Then there is a android:viewportheight and Android:viewportwidth attribute, this is the canvas width is high, is also required, the definition path path must be in this canvas size to draw, beyond the canvas will not show.

The path label Android:fillcolor property defines the drawing color, Android:pathdata defines the drawing path.

m25,0 l 50,50-50,50z This path means: In the 100*100 canvas, first move the plot point to the absolute coordinates (25,0) this point, and then draw a straight line to (50,50) this point, l instruction is relative coordinates, uppercase L is the absolute coordinate, then L 50,50 is at the origin point (25,0) The x-axis moves forward 50, moving down 50, the absolute coordinate is (75,50), that is, the triangle to the right of the point.
Then draw from this point (50,50) to the bottom of the triangle Point ( -50,50), which is relative to the right of the point relative coordinates, that is, the absolute coordinates (75,50) as the origin (0,0), the origin of the point to move backward 50 and Move down 50, the entire canvas is the absolute coordinates is (25,100)

Study on the vectordrawable of androidの vector graphics

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.