build be tu er android apps with vector assets
play

Build be tu er Android apps, with vector assets @LukeSleeman @ - PowerPoint PPT Presentation

Build be tu er Android apps, with vector assets @LukeSleeman @ MarcEdwards (Itty Bitty Apps) (Bjango) Outline What are vector assets? Creating and exporting SVGs Converting SVGs to VectorDrawables Using VectorDrawables in your


  1. Build be tu er Android apps, 
 with vector assets @LukeSleeman 
 @ MarcEdwards 
 (Itty Bitty Apps) (Bjango)

  2. Outline What are vector assets? Creating and exporting SVGs Converting SVGs to VectorDrawables Using VectorDrawables in your apps The Marc and Luke 4 step plan Questions?

  3. What are vector assets? Vector Bitmap

  4. What are the benefits of vector assets? Smaller files and faster loading. One file for all pixel densities. Dynamic colours, and other dynamic drawing. Did we mention smaller files? Smaller files!*

  5. What are the drawbacks? Vector assets can have performance issues. Can use a lot of memory while rendering. Can only be used for certain things. Choose wisely!

  6. What are SVGs? Scalable Vector Graphics files. XML files, containing shapes, paths and styling data. Initially released in 2001, but increasingly popular. SVG 2.0 is in flux right now. Pronounced with a hard G.

  7. What are Vector Drawables? Android specific vector format. Subset of SVG: 
 Supports group, path, clipPath, and transforms. Quicker and easier to render than SVG. This image is pretty ugly and blurry. If its quick and easy to do re-draw it, otherwise we will just live with it

  8. Example Vector Drawable

  9. Example Vector Drawable

  10. Example Vector Drawable

  11. Example Vector Drawable

  12. When should you use vector assets? Maybe? 🤕 Yes! No way.

  13. 223.1 MB

  14. Creating vector assets Illustrator Photoshop Sketch A ffi nity Designer

  15. Best practices for creating vector assets Create using a 1dp grid. “Flatten” or combine boolean operations. If you use text, outline it. Remove redundant points.

  16. Create using a 1dp grid

  17. “Fla tu en” or combine boolean operations

  18. “Fla tu en” or combine boolean operations

  19. Outline text

  20. Remove redundant points

  21. Remove redundant points 😳

  22. Exporting SVGs As automated as possible. Faster, and less mistakes. Less e ff ort to make changes.

  23. iStat Menus prefs app export document

  24. Exporting SVGs from Illustrator Create artwork on artboards. Export with Export for Screens. 100 artboard limit? 1000 artboards!

  25. Exporting SVGs from Photoshop Create artwork on artboards or in groups. Export with Export As or Generator. Don’t use Photoshop? Or use Photoshop + PaintCode!

  26. Exporting SVGs from Sketch Create artwork on artboards or in groups. Export with Make Exportable. Slices are good!

  27. Exporting SVGs from A ffi nity Create artwork on artboards or in groups. Export with Export Persona. Slices are good!

  28. Converting SVGs to VectorDrawables We have ✨ SVG’s ✨ 🤕 Now how to get VectorDrawables?

  29. What do you mean ‘complex’? Features that cause problems: It would be nice if we could somehow clip paths visually show what these things are. I think it may be a bit to much work to draw up examples of each of them though Inner and outer strokes gradient fill (7.0, SDK 24+) fill rule - evenodd, etc (7.0 SDK 24+) transforms <defs>

  30. 4 Ways of converting 1. Android Studio import 2. http://inloop.github.io/svg2android/ 3. http://a-student.github.io/ SvgToVectorDrawableConverter.Web/ 4. PaintCode

  31. #1 - Android Studio

  32. #2 - SVG2Android http://inloop.github.io/svg2android/

  33. #3 - SvgToVectorDrawableConverter.Web http://a-student.github.io/SvgToVectorDrawableConverter.Web/

  34. #4 - PaintCode If you have a more relevant screenshot of paint code go for it - this was just from their website

  35. Lets put them to the test! Clip paths Inner stroke Gradient Fill rule Transform <Defs>

  36. This turned out to be a lot of work …

  37. The results!

  38. Recommendation: PaintCode SVG2Android a close second also Keep checking Android Studio for updates: https:// issuetracker.google.com/issues/37092389

  39. Now to use them in the app Easy right? 😆

  40. Again - lots of options! 1. Native vector drawable generation 2. Native for 5.0 and up, PNG generation through gradle for backwards compatibility 3. support-vector-drawable library

  41. Native Vector Drawable support Add your vector drawable xml file to res/drawable/ Reference it like any other drawable API 21 (Android 5.0) has native support API 24 (Android 7) has better support - Fill types 
 (even-odd), gradient fill Other misc bugs in android 5.0 and 6.0

  42. Cool feature - can reference colours.xml

  43. Vectors aren’t always sharp 😴

  44. 100dp 100dp

  45. Native SVG - PNG Generation Set minSdkVersion < 21, eg below android 5.0 No build changes required at all - just drop in Vector Drawable to project! Only supports limited set of elements Cant reference colours.xml from xml

  46. PNG Generation APK contents:

  47. PNG Generation APK contents:

  48. PNG Generation APK contents:

  49. Backwards compatibility library support-vector-drawable Backwards compatibility library which extends Drawable to create VectorDrawableCompat Uses VectorDrawableCompat when running below API 24 (Android 7). API 24+ it uses native implementation Allows you to get vector drawable features only supported in API 24 Vectors are Sharp on all API levels! Can use colors.xml values

  50. Backwards compatibility library support-vector-drawable - gradle changes

  51. Backwards compatibility library support-vector-drawable - gradle changes

  52. Backwards compatibility library support-vector-drawable - gradle changes

  53. Backwards compatibility library support-vector-drawable - Code changes

  54. Backwards compatibility library support-vector-drawable - Code changes

  55. The magical se tu ing to turn on

  56. Recommendation: support-vector-drawable Perhaps native if your are targeting API 23 (Android 6.0) and up

  57. The Marc and Luke 4 step plan 1. Create clean artwork 2. Export like this 3. Converting to VectorDrawable 4. Displaying VectorDrawables

  58. 1. Create clean artwork Create using a 1dp grid. “Flatten” or combine boolean operations. If you use text, outline it. Remove redundant points.

  59. 2. Export like this Illustrator, using artboards and Export for Screens Sketch, using Make Exportable A ffi nity Designer, using Slices Photoshop, by importing into PaintCode

  60. 3. Converting to VectorDrawable Use PaintCode If you cant use that - try SVG2Andoid Keep checking for those Android Studio updates …

  61. 4. Displaying VectorDrawables Use support-vector-drawable If you are only supporting the latest versions of Android, perhaps native will work

  62. Questions? @LukeSleeman 
 @ MarcEdwards 
 (Itty Bitty Apps) (Bjango)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend