vector drawable api. Возможности применения

39
Vector Drawable API возможности применения Олег Осипенко [email protected] [email protected]

Upload: rambler-android

Post on 18-Jan-2017

567 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Vector Drawable API. Возможности применения

Vector Drawable APIвозможности применения

Олег Осипенко [email protected]

[email protected]

Page 2: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Компьютерная графика• Bitmap • Векторные изображения

Page 3: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Компьютерная графика• Bitmap • Векторные изображения

Масштабирование

16х

16х

Page 4: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Компьютерная графика• Bitmap • Векторные изображения

• прямая зависимость размера файла от размера изображения

Page 5: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Flat & Material Design• Windows Metro interface • iOS 7 • Material Design в Lollipop

Page 6: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Flat & Material Design• отказ от скевоморфизма • четкие контуры,

плоские заливки • упор на типографику

Page 7: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Flat & Material Design• Bauhaus, швейцарская школа типографики

Page 8: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Иконография Material Design

Page 9: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableструктура

<vector android:width="290dp" android:height="48dp" android:viewportWidth="290" android:viewportHeight="48" >

</vector>

Page 10: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableструктура

<vector android:width="290dp" android:height="48dp" android:viewportWidth="290" android:viewportHeight="48" >

</vector>

Page 11: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableviewport

android:width="272dp" android:height="290dp" android:viewportWidth="272" android:viewportHeight="290"

Page 12: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableviewport

android:width="272dp" android:height="290dp" android:viewportWidth="600" android:viewportHeight="600"

Page 13: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableviewport

android:width="272dp" android:height="290dp" android:viewportWidth="100" android:viewportHeight="100"

Page 14: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableviewport

• отсутствует возможность указать PivotPoint

• TopLeft by default

Page 15: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableструктура

<vector android:name android:tint android:tintMode android:autoMirrored android:alpha> <vector/>

Page 16: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Элемент Path<path android:pathData="M141.4,188.2H51V329c0,15.4,16.4,15.5,16.4,

15.5l20.8,0v19.7h0c0,0.3,0,0.5,0,0.8c0,11,8.9,19.9,19.9,19.9c11, 0,19.9-8.9,19.9-19.9c0-0.3,0-0.5,0-0.8h0v-19.7l13.4,0l13.4,0v19.7h0c0, 0.3,0,0.5,0,0.8c0,11,8.9,19.9,19.9,19.9c11,0,19.9-8.9,19.9-19.9c0-0.3, 0-0.5,0-0.8h0v-19.7l20.8,0c0,0,16.4,0,16.4-15.5V188.2H141.4z"

Page 17: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Элемент PathPath в Android и Path в SVG

Page 18: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Элемент Path<path android:pathData android:fillColor, android:fillAlpha android:strokeColor, android:strokeWidth, android:strokeAlpha android:trimPathStart, android:trimPathEnd, android:trimPathOffset android:strokeLineCap, android:strokeLineJoin, android:strokeMiterLimit />

Page 19: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс VectorDrawableНесколько объектов Path можно объединить в группу

<group android:name android:rotation android:pivotX, pivotY android:scaleX, scaleY android:translateX, translateY> <group/>

Page 20: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс AnimatedVectorDrawable<animated-vector android:drawable="@drawable/vector_drawable">

</animated-vector>

Page 21: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс AnimatedVectorDrawable<animated-vector android:drawable="@drawable/vector_drawable">

<target android:name="head" android:animation="@anim/headAnimation" />

</animated-vector>

Page 22: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс AnimatedVectorDrawable<animated-vector android:drawable="@drawable/vector_drawable">

<target android:name="head" android:animation="@anim/headAnimation" />

</animated-vector>

Page 23: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс AnimatedVectorDrawableTarget - любой атрибут Path или Group

Поддерживается несколько target в одном AnimatedVectorDrawable

<animated-vector android:drawable="@drawable/vector_drawable">

<target /> <target /> <target />

</animated-vector>

Page 24: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Класс AnimatedVectorDrawableнесколько target -

несколько анимаций

Page 25: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Animationновый valueType

<set> <objectAnimator android:duration="400" android:propertyName="pathData" android:valueType="pathType" />

</set>

Page 26: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Animationатрибут PathData

<set> <objectAnimator android:duration="400" android:propertyName="pathData" android:valueType="pathType" android:valueFrom="@string/pathFrom" android:valueTo="@string/pathTo" />

</set>

Page 27: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

AnimationpathFrom и pathTo должны иметь одинаковое количество и тип команд<set> <objectAnimator android:duration="400" android:propertyName="pathData" android:valueType="pathType" android:valueFrom="@string/pathFrom" android:valueTo="@string/pathTo" />

</set>

Page 28: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Запуск анимации((Animatable) imageView.getBackground()).start();

• отсутствует возможность настройки хореографии • отсутствует AnimationListener • возможный вариант Handler.postDelayed(Runnable r)

Page 29: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Запуск анимацииinterface Animatable2

void registerAnimationCallback(AnimationCallback cb)

class AnimationCallbackvoid onAnimationStart()

void onAnimationEnd()

Page 30: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Обратная поддержкабиблиотека VectorCompat

https://github.com/wnafee/vector-compat

min SDK 14• загрузка VectorDrawable либо AnimatedVectorDrawable ResourcesCompat.getDrawable(context, R.drawable.any_drawable);

на устройствах с Lollipop - через native API

build.tools >= 22.0.1

Page 31: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Обратная поддержкадублирование атрибутов

<vector android:width="290dp" android:height="48dp" android:viewportHeight="48" app:vc_viewportHeight="48" app:vc_viewportWidth="290" android:viewportWidth="290"> </vector>

Page 32: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Обратная поддержкадублирование атрибутов

<path android:name="btn_signin" android:fillColor="@color/btn_signin" app:vc_fillColor="@color/btn_signin" android:pathData="@string/btn_signin_from" app:vc_pathData="@string/btn_signin_from" />

Page 33: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Обратная поддержкадублирование атрибутов

<objectAnimator android:valueType="pathType" app:vc_valueType="pathType" />

Page 34: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Обратная поддержкаособенности запуска

только в runtime

AnimatedVectorDrawable avd = ResourcesCompat .getDrawable(context, R.drawable.any_drawable);

imageView.setBackground(avd);

((Animatable) avd).start();

Page 35: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Page 36: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

VectAlignинструмент для выравнивания двух путей для создания pathAnimation

https://github.com/bonnyfone/vectalign

BetterVectorDrawableбиблиотека поддержки, API >= 14

https://github.com/a-student/BetterVectorDrawable

Page 37: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Vector Asset Studio• создание XML файлов

Vector Drawable из SVG • Android Studio >= 1.4 • File > New > Vector Asset

Page 38: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Вопросы?

Page 39: Vector Drawable API. Возможности применения

Vector Drawable API возможности применения

Спасибо за внимание!