Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Animation祭り!!!

sasami
August 06, 2017

Android Animation祭り!!!

【東京】【女性限定】言語不問!浴衣でビールクズミニセッション大会#javajo(https://javajo.doorkeeper.jp/events/63154 )で発表した内容です

sasami

August 06, 2017
Tweet

More Decks by sasami

Other Decks in Technology

Transcript

  1. ϑΝΠϧͷม׵ • png->svg
 - ม׵πʔϧ(http://www.autotracer.org/) • svg->vectorDrawable
 Vector Assets Studio࢖༻(https://developer.android.com/

    studio/write/vector-asset-studio.html?hl=ja)
 - Google Material Designͷ৔߹༻ҙ͞Ε͍ͯΔ΋ͷΛ࢖ ༻Ͱ͖·͢(https://material.io/icons/)

  2. Animated Vector DrawableͰ Ͱ͖Δ͜ͱ • Rotation • Morph(ผͷܗʹม͑Δ) • Color,

    position, sizeΛม͑Δ͜ͱ͕Ͱ͖Δ Source: https://dribbble.com/shots/1618281- Material-Design-Animation
  3. 1. //vd.xml <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="64dp" android:width="64dp" android:viewportHeight="600" android:viewportWidth="600" > <group

    android:name="rotationGroup" android:pivotX="300.0" android:pivotY="300.0" android:rotation="45.0" > <path android:name="vectorPath" android:fillColor="#000000" android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" /> </group> </vector>
  4. 3. //rotation.xml <objectAnimator android:duration="6000" android:propertyName="rotation" android:valueFrom="0" android:valueTo="360" /> //path_morph <set

    xmlns:android="http://schemas.android.com/apk/res/android"> <objectAnimator android:duration="3000" android:propertyName="pathData" android:valueFrom="M300,70 l 0,-70 70,70 0,0 -70,70z" android:valueTo="M300,70 l 0,-70 70,0 0,140 -70,0 z" android:valueType="pathType"/> ɹ</set>

  5. ͜Μͳײ͡Ͱ·ͱΊΔ͜ͱ΋ <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"> <aapt:attr name="android:drawable"> <vector android:width="24dp" android:height="24dp" android:viewportWidth="24"

    android:viewportHeight="24"> <path android:name="root" android:strokeWidth="2" android:strokeLineCap="square" android:strokeColor="?android:colorControlNormal" android:pathData="M4.8,13.4 L9,17.6 M10.4,16.2 L19.6,7" /> </vector> </aapt:attr> <target android:name="root"> <aapt:attr name="android:animation"> <objectAnimator android:propertyName="pathData" android:valueFrom="M4.8,13.4 L9,17.6 M10.4,16.2 L19.6,7" android:valueTo="M6.4,6.4 L17.6,17.6 M6.4,17.6 L17.6,6.4" android:duration="300" android:interpolator="@android:interpolator/fast_out_slow_in" android:valueType="pathType" /> </aapt:attr> </target> </animated-vector>
  6. ؔ࿈class • Android.support.animation
 animationʹؔ͢ΔओཁͳAPI • DynamicAnimation
 physics-based animationͷϕʔεclass • SpringAnimation


    DynamicAnimationͷsub-class. Spring animationΛ࡞੒ • SpringForce
 springʹؔ͢ΔϓϩύςΟΛఆٛ • FlingAnimation
 DynamicAnimationͷsub-class. fling animationΛ࡞੒
  7. ࡞Γํ final View img = findViewById(R.id.imageView); final SpringAnimation springAnim =

    new SpringAnimation(img, DynamicAnimation.TRANSLATION_Y, 0); // springAnim.start()