SlideShare a Scribd company logo
Vector Drawable
SVG
Tutorial (Android)
Mr. THANN Phearum,
Associate Software Engineering
Outline
- Intro.
- Icon Sizes
- Implement
- Demo
- Ref.
Intro.
- SVG?
● SVG stands for Scalable Vector Graphics
● SVG is used to define vector-based graphics for the Web
● SVG defines the graphics in XML format
● SVG graphics do NOT lose any quality if they are zoomed or resized
● Every element and every attribute in SVG files can be animated
● SVG is a W3C recommendation
● SVG integrates with other W3C standards such as the DOM and XSL
Source: http://www.w3schools.com/svg/
Into. (cont.)
- Example
<svg xmlns="http://www.w3.org/2000/svg"
width="48" height="48" viewBox="0 0 48 48">
<path d="M38 16H10c-3.31 0-6 2.69-6
6v12h8v8h24v-8h8V22c0-3.31-2.69-6-6-6zm-6
22H16V28h16v10zm6-14c-1.11 0-2-.89-2-2s.
89-2 2-2c1.11 0 2 .89 2 2s-.89 2-2 2zM36
6H12v8h24V6z"/>
</svg>
ic_printer.svg
NOTE: (width="48" and height="48") is baseline size to scale the image
Into. (cont.)
- Tools to create .svg
Illustrator (WIndow, Mac)
InkScape (Linux)
Icon Sizes
Android icons require five separate sizes for different screen pixel densities.
Icon Sizes (cont.)
Android also classify the icon into four types
- Small Contextual
Small icons are used to surface actions and/or provide status for specific items.
For example, in the Gmail app, each message has a star icon that marks the message as important.
- Notification
These are used to represent application notifications in the status bar. They should be flat (no
gradients), white and face-on perspective
- Actionbar, Dialog & Tab
These icons are used in the action bar menu. The first number is the size of the icon area, and the
second is file size.
- Launcher
Three-dimensional, front view, with a slight perspective as if viewed from above, so that users
perceive some depth.
Icon Sizes (cont.)
- Small Contextual - Notification
16 × 16 (mdpi)
24 × 24 (hdpi)
32 × 32 (xhdpi)
48 × 48 (xxhdpi)
64 × 64 (xxxhdpi)
22 × 22 area in 24 × 24 (mdpi)
33 × 33 area in 36 × 36 (hdpi)
44 × 44 area in 48 × 48 (xhdpi)
66 × 66 area in 72 × 72 (xxhdpi)
88 × 88 area in 96 × 96 (xxxhdpi)
Icon Sizes (cont.)
- Actionbar - Launcher
24 × 24 area in 32 × 32 (mdpi)
36 × 36 area in 48 × 48 (hdpi)
48 × 48 area in 64 × 64 (xhdpi)
72 × 72 area in 96 × 96 (xxhdpi)
96 × 96 area in 128 × 128 (xxxhdpi)
48 × 48 (mdpi)
72 × 72 (hdpi)
96 × 96 (xhdpi)
144 × 144 (xxhdpi)
192 × 192 (xxxhdpi)
Icon Sizes (cont.)
- Example
Actionbar, Dialog & Tab
24 × 24 area in 32 × 32 (mdpi)
Implement
- Victor
Android plugin library to use .svg as resources.
It supports from Android 2.x.
Source: https://github.com/trello/victor
Implement (cont.)
- Victor Installation
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.trello:victor:0.1.4'
}
}
apply plugin: 'com.android.application'
// Make sure to apply this plugin *after* the Android plugin
apply plugin: 'com.trello.victor'
Implement (cont.)
- Victor Known Issues
Android Studio doesn't recognize generated resources in XML.
<ImageView
android:id="@+id/img_mdpi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/margin_small"
android:src="@drawable/ic_person" />
Implement (cont.)
- Victor Example Code
We can set drawable to the ImageView in Java file.
@Bind(R.id.img_mdpi)
ImageView imgMdpi;
imgMdpi.setImageResource(R.drawable. ic_person);
Demo
I have create a sample application to test with vector
drawable. Please check.
https://github.com/THANNPhearum/GGVectorDrawable
 Android Vector Drawable
Ref.
- SVG def.
http://www.w3schools.com/svg/
- Android Icons Size
http://iconhandbook.co.uk/reference/chart/android/
- Victor Android Library
https://github.com/trello/victor

More Related Content

PDF
Android 2D Drawing and Animation Framework
PDF
Android graphics
PPTX
HTML 5 Canvas & SVG
PPTX
HTML 5_Canvas
PPTX
Introduction to HTML5 Canvas
PDF
Html5 canvas
PPTX
Drawing with the HTML5 Canvas
PDF
Intro to HTML5 Canvas
Android 2D Drawing and Animation Framework
Android graphics
HTML 5 Canvas & SVG
HTML 5_Canvas
Introduction to HTML5 Canvas
Html5 canvas
Drawing with the HTML5 Canvas
Intro to HTML5 Canvas

What's hot (14)

PDF
Canvas - HTML 5
PDF
HTML5 Canvas - The Future of Graphics on the Web
PPT
HTML5 Canvas
PPTX
HTML CANVAS
PPTX
SVG, CSS3, and D3 for Beginners
PPTX
Svcc 2013-css3-and-mobile
PDF
Mpdf51demo
KEY
Interactive Graphics
PPTX
HTML5 Animation in Mobile Web Games
PDF
D3.js 30-minute intro
PPTX
Kotlin Mullets
PDF
Visualization of Big Data in Web Apps
PDF
From Shabby to Chic
PPT
Chapter 13
Canvas - HTML 5
HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas
HTML CANVAS
SVG, CSS3, and D3 for Beginners
Svcc 2013-css3-and-mobile
Mpdf51demo
Interactive Graphics
HTML5 Animation in Mobile Web Games
D3.js 30-minute intro
Kotlin Mullets
Visualization of Big Data in Web Apps
From Shabby to Chic
Chapter 13
Ad

Viewers also liked (11)

PDF
Android Vector drawable
PDF
Vector Drawable API. Возможности применения
PDF
Революционный Android. Ищем замену фрагментам
PPTX
Bitmap vs vectors image
PPT
Vectors and Rasters
PPTX
What's new in Android at I/O'16
PDF
Bitmap and Vector Images: Make Sure You Know the Differences
PPT
Raster vs vector graphics
PPTX
Vectors vs Rasters, Graphic Formats
PPT
Raster Vs. Vector Presentation1
PPTX
Android User Interface Design
Android Vector drawable
Vector Drawable API. Возможности применения
Революционный Android. Ищем замену фрагментам
Bitmap vs vectors image
Vectors and Rasters
What's new in Android at I/O'16
Bitmap and Vector Images: Make Sure You Know the Differences
Raster vs vector graphics
Vectors vs Rasters, Graphic Formats
Raster Vs. Vector Presentation1
Android User Interface Design
Ad

Similar to Android Vector Drawable (18)

PDF
SVG Strikes Back
PPTX
UI and UX for Mobile Developers
PPT
Deep Dive Xamarin.Android
PPTX
Android design lecture #1
PPTX
Consistent UI Across Android Devices
PDF
Advanced Android Design Implementation
PPTX
Visual Aspects of Mobile UI Design Standards
PDF
Supporting multiple screens on android
PDF
Multi Screen Hell
PDF
Android training day 3
PDF
Android Fragment-Awesome
PDF
Coding for different resolutions
PDF
Adaptive Design for Android
PDF
Android casting-wide-net-android-devices
PDF
Android Workshop - Session 2
PDF
Android resources
PPT
Android Developer Meetup
PDF
Chapter 9 - Resources System
SVG Strikes Back
UI and UX for Mobile Developers
Deep Dive Xamarin.Android
Android design lecture #1
Consistent UI Across Android Devices
Advanced Android Design Implementation
Visual Aspects of Mobile UI Design Standards
Supporting multiple screens on android
Multi Screen Hell
Android training day 3
Android Fragment-Awesome
Coding for different resolutions
Adaptive Design for Android
Android casting-wide-net-android-devices
Android Workshop - Session 2
Android resources
Android Developer Meetup
Chapter 9 - Resources System

Recently uploaded (6)

PDF
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
DOC
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
PDF
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
PDF
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
PPTX
ASMS Telecommunication company Profile
DOC
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
ASMS Telecommunication company Profile
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证

Android Vector Drawable

  • 1. Vector Drawable SVG Tutorial (Android) Mr. THANN Phearum, Associate Software Engineering
  • 2. Outline - Intro. - Icon Sizes - Implement - Demo - Ref.
  • 3. Intro. - SVG? ● SVG stands for Scalable Vector Graphics ● SVG is used to define vector-based graphics for the Web ● SVG defines the graphics in XML format ● SVG graphics do NOT lose any quality if they are zoomed or resized ● Every element and every attribute in SVG files can be animated ● SVG is a W3C recommendation ● SVG integrates with other W3C standards such as the DOM and XSL Source: http://www.w3schools.com/svg/
  • 4. Into. (cont.) - Example <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"> <path d="M38 16H10c-3.31 0-6 2.69-6 6v12h8v8h24v-8h8V22c0-3.31-2.69-6-6-6zm-6 22H16V28h16v10zm6-14c-1.11 0-2-.89-2-2s. 89-2 2-2c1.11 0 2 .89 2 2s-.89 2-2 2zM36 6H12v8h24V6z"/> </svg> ic_printer.svg NOTE: (width="48" and height="48") is baseline size to scale the image
  • 5. Into. (cont.) - Tools to create .svg Illustrator (WIndow, Mac) InkScape (Linux)
  • 6. Icon Sizes Android icons require five separate sizes for different screen pixel densities.
  • 7. Icon Sizes (cont.) Android also classify the icon into four types - Small Contextual Small icons are used to surface actions and/or provide status for specific items. For example, in the Gmail app, each message has a star icon that marks the message as important. - Notification These are used to represent application notifications in the status bar. They should be flat (no gradients), white and face-on perspective - Actionbar, Dialog & Tab These icons are used in the action bar menu. The first number is the size of the icon area, and the second is file size. - Launcher Three-dimensional, front view, with a slight perspective as if viewed from above, so that users perceive some depth.
  • 8. Icon Sizes (cont.) - Small Contextual - Notification 16 × 16 (mdpi) 24 × 24 (hdpi) 32 × 32 (xhdpi) 48 × 48 (xxhdpi) 64 × 64 (xxxhdpi) 22 × 22 area in 24 × 24 (mdpi) 33 × 33 area in 36 × 36 (hdpi) 44 × 44 area in 48 × 48 (xhdpi) 66 × 66 area in 72 × 72 (xxhdpi) 88 × 88 area in 96 × 96 (xxxhdpi)
  • 9. Icon Sizes (cont.) - Actionbar - Launcher 24 × 24 area in 32 × 32 (mdpi) 36 × 36 area in 48 × 48 (hdpi) 48 × 48 area in 64 × 64 (xhdpi) 72 × 72 area in 96 × 96 (xxhdpi) 96 × 96 area in 128 × 128 (xxxhdpi) 48 × 48 (mdpi) 72 × 72 (hdpi) 96 × 96 (xhdpi) 144 × 144 (xxhdpi) 192 × 192 (xxxhdpi)
  • 10. Icon Sizes (cont.) - Example Actionbar, Dialog & Tab 24 × 24 area in 32 × 32 (mdpi)
  • 11. Implement - Victor Android plugin library to use .svg as resources. It supports from Android 2.x. Source: https://github.com/trello/victor
  • 12. Implement (cont.) - Victor Installation buildscript { repositories { jcenter() } dependencies { classpath 'com.trello:victor:0.1.4' } } apply plugin: 'com.android.application' // Make sure to apply this plugin *after* the Android plugin apply plugin: 'com.trello.victor'
  • 13. Implement (cont.) - Victor Known Issues Android Studio doesn't recognize generated resources in XML. <ImageView android:id="@+id/img_mdpi" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="@dimen/margin_small" android:src="@drawable/ic_person" />
  • 14. Implement (cont.) - Victor Example Code We can set drawable to the ImageView in Java file. @Bind(R.id.img_mdpi) ImageView imgMdpi; imgMdpi.setImageResource(R.drawable. ic_person);
  • 15. Demo I have create a sample application to test with vector drawable. Please check. https://github.com/THANNPhearum/GGVectorDrawable
  • 17. Ref. - SVG def. http://www.w3schools.com/svg/ - Android Icons Size http://iconhandbook.co.uk/reference/chart/android/ - Victor Android Library https://github.com/trello/victor