Android_svg Overview and generation using SVG details

Source: Internet
Author: User

1.


2.svg-path Path
The following commands are available for path data:
M = MoveTo
L = LineTo
H = Horizontal LineTo
V = Vertical LineTo
C = Curveto
S = Smooth Curveto
Q = Quadratic Belzier curve
T = smooth quadratic belzier curveto
A = Elliptical ARC
Z = Closepath
Note: All commands above allow lowercase letters. Uppercase indicates absolute positioning, and lowercase indicates relative positioning.

Please copy the following code to Notepad and save the file as "Path1.svg". Put this file in your Web directory:

<?xml version= "1.0" standalone= "no"? ><! DOCTYPE svg public "-//W3C//DTD svg 1.1//en" "Http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" ><svg width= "100 % "height=" 100% "version=" 1.1 "xmlns=" Http://www.w3.org/2000/svg "><path d=" M250 L150-L350-Z "/></ Svg>

The above example defines a path that starts at position 250 150, arrives at position 150 350, then starts from there to 350 350, and finally closes the path in 250 150.


3. Image generation in SVG format

It is recommended to use the GIMP tool to generate the following steps:




Based on the above, locate the path and save it.


To the Path dialog box, export the path


<?xml version= "1.0" encoding= "UTF-8" standalone= "no"? ><! DOCTYPE svg public "-//W3C//DTD svg 20010904//en" "Http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" & Gt;<svg xmlns= "Http://www.w3.org/2000/svg" width= "1.77778in" height= "1.77778in" viewbox= "0 0" > < Path id= "Selection" fill= "None" stroke= "Black" stroke-width= "1" d= "M 108.54,26.04 C 131.59,52.94 125.04,9             7.93 93.00,114.74 79.15,122.00 75.25,122.17 60.00,122.00 22.32,121.56-2.52,80.38 8.75,46.00           16.01,23.85 33.60,10.58 56.00,6.44 75.35,3.96 95.68,11.04 108.54,26.04 Z M 56.97,45.15 C 52.64,43.32 36.54,44.00 31.00,44.00 31.00,44.00 31.00,76.00 31.00,76.00 31.02,78.13 30.74,81             .51 32.60,82.98 34.49,84.47 42.35,84.00 45.00,84.00 49.96,83.99 56.82,83.94 60.73,80.43 66.36,75.36 66.06,66.13 56.97,63.00 56.97,63.00 56.97,61.00 56.97,61.00 65.30,56.20 63.38,47.91 56.97,45.15 Z M 75.00,47.00 C 75.00,47.00 75.00,49.00 75.00,4 9.00 75.00,49.00 90.00,49.00 90.00,49.00 90.00,49.00 90.00,47.00 90.00,47.00 90.00,47. XX 75.00,47.00 75.00,47.00 Z M 53.69,50.02 C 56.68,52.02 56.68,57.83 53.69,59.83 51.13,61.  53 42.36,61.00 39.00,61.00 39.00,61.00 39.00,49.00 39.00,49.00 42.16,49.00 51.36,48.47 53.69,50.02 Z M 90.00,71.00 C 101.61,70.78 95.70,60.78 91.70,57.84 81.22,50.14 65.06,59.66 68.95,74.0 0 72.11,85.62 91.42,89.31 96.00,75.95 89.20,76.54 82.26,84.08 76.93,75.95 76.03,74.51 75.51,72.57 75.00,71.00 75.00,71.00 90.00,71.00 90.00,71.00 Z M 91.00,67.00 C 91.00,67.00 75.00,67.00 75.00,67.00 77.80,56.34 89.44,55.99 91.00,67.00 Z M 48.00,65.14 C 49.46,65.02 51.56,65.02 52.95,65.14            57.94,66.90 59.11,73.01 55.57,76.57 52.93,79.23 48.51,79.13 45.00,78.98 42.86,78.89 40 .68,78.89 39.60,76.69 38.72,74.89 39.00,67.39 39.00,65.14 39.00,65.14 48.00,65.14 48.00,65.14 Z "/ ></svg>
If the Path dialog box is not found, you can find the



4. How to implement

This is where SVG is loaded using the Androidfillableloaders framework, and more can be viewed by author articles http://jorgecastillo.xyz/2015/08/16/android-fillable-loaders/

<com.github.jorgecastillo.fillableloader  android:id= "@+id/fillableloader"  android:layout_width= " 200DP "  android:layout_height=" 100DP "  app:fl_originalwidth=" @integer/original_svg_width "  app:fl_ originalheight= "@integer/original_svg_height"  app:fl_strokecolor= "@color/stroke_color"  app:fl_ Fillcolor= "@color/fill_color"  app:fl_strokewidth= "@dimen/stroke_width"  app:fl_strokedrawingduration= "@integer/stroke_drawing_duration"  app:fl_fillduration= "@integer/fill_duration"  app:fl_ Clippingtransform= "Waves"  />
@Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);    Setcontentview (R.layout.activity_main); String svg = "M 108.54,26.04\n" + "C 131.59,52.94 125.04,97.93 93.00,114.74\n" + "79.15,122.00 75.2 5,122.17 60.00,122.00\n "+" 22.32,121.56-2.52,80.38 8.75,46.00\n "+" 16.01,23.85 33.60,10.58 56.0 0,6.44\n "+" 75.35,3.96 95.68,11.04 108.54,26.04 z\n "+" M 56.97,45.15\n "+" C 52.64,43.  36.54,44.00 31.00,44.00\n "+" 31.00,44.00 31.00,76.00 31.00,76.00\n "+" 31.02,78.13 30.74,81.51 32.60,82.98\n "+" 34.49,84.47 42.35,84.00 45.00,84.00\n "+" 49.96,83.99 56.82,83.94 60.73,80.43\n            "+" 66.36,75.36 66.06,66.13 56.97,63.00\n "+" 56.97,63.00 56.97,61.00 56.97,61.00\n "+ "65.30,56.20 63.38,47.91 56.97,45.15 z\n" + "M 75.00,47.00\n" + "C 75.00,47.00 75.00,49.00 75.00,49.00\n "+" 75.00,49.00 90.00,49.00 90.00,49.00\n "+" 90.00,49.00 90.00,47.00 90.00,47.00\n "+ "90.00,47.00 75.00,47.00 75.00,47.00 z\n" + "M 53.69,50.02\n" + "C 56.68,52.02 56.68,57.83  53.69,59.83\n "+" 51.13,61.53 42.36,61.00 39.00,61.00\n "+" 39.00,61.00 39.00,49.00 39.00,49.00\n " + "42.16,49.00 51.36,48.47 53.69,50.02 z\n" + "M 90.00,71.00\n" + "C 101.61,70.78 95.70 , 60.78 91.70,57.84\n "+" 81.22,50.14 65.06,59.66 68.95,74.00\n "+" 72.11,85.62 91.42,89.31 96.00,7            5.95\n "+" 89.20,76.54 82.26,84.08 76.93,75.95\n "+" 76.03,74.51 75.51,72.57 75.00,71.00\n "+ "75.00,71.00 90.00,71.00 90.00,71.00 z\n" + "M 91.00,67.00\n" + "C 91.00,67.00 75.00,67.00 7 5.00,67.00\n "+" 77.80,56.34 89.44,55.99 91.00,67.00 z\n "+" M 48.00,65.14\n "+" C 49.46 , 65.02 51.56,65.02 52.95, 65.14\n "+" 57.94,66.90 59.11,73.01 55.57,76.57\n "+" 52.93,79.23 48.51,79.13 45.00,78.98\n "+ "42.86,78.89 40.68,78.89 39.60,76.69\n" + "38.72,74.89 39.00,67.39 39.00,65.14\n" + "39.    00,65.14 48.00,65.14 48.00,65.14 Z ";    Fillableloader = (fillableloader) Findviewbyid (R.id.fillableloader); Generate SVG as a string to pass in Fillableloader.setsvgpath (SVG);}
Findviewbyid (R.ID.BTN). Setonclicklistener (New View.onclicklistener () {    @Override public    void OnClick (View View) {        //Open        Fillableloader.start ();    }});

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android_svg Overview and generation using SVG details

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.