1page.title=사용자지정 애니메이션의 정의 2 3@jd:body 4 5<div id="tb-wrapper"> 6<div id="tb"> 7<h2>이 과정에서 다루는 내용</h2> 8<ol> 9 <li><a href="#Touch">사용자지정 터치 피드백</a></li> 10 <li><a href="#Reveal">표시 효과 사용</a></li> 11 <li><a href="#Transitions">사용자지정 액티비티 전환</a></li> 12 <li><a href="#ViewState">뷰 상태 변경 애니메이트</a></li> 13 <li><a href="#AnimVector">벡터 드로어블 애니메이트</a></li> 14</ol> 15<h2>필독 항목</h2> 16<ul> 17 <li><a href="http://www.google.com/design/spec">머티리얼 디자인 사양</a></li> 18 <li><a href="{@docRoot}design/material/index.html">Android의 머티리얼 디자인</a></li> 19</ul> 20</div> 21</div> 22 23 24<p>머티리얼 디자인에서 애니메이션은 사용자에게 자신의 동작에 대한 피드백을 제공하고, 앱과 상호작용할 때 시각적 연속성을 제공합니다. 25 머티리얼 테마는 버튼 및 액티비티 전환을 위한 몇 가지 기본 애니메이션을 제공합니다. Android 5.0(API 레벨 21) 이상에서는 이러한 애니메이션을 사용자가 지정하거나 새로운 애니메이션을 만들 수 있습니다. 26 27</p> 28 29<ul> 30<li>터치 피드백</li> 31<li>회전하며 나타나기</li> 32<li>액티비티 전환</li> 33<li>커브 모션</li> 34<li>뷰 상태 변경</li> 35</ul> 36 37 38<h2 id="Touch">사용자지정 터치 피드백</h2> 39 40<p>머티리얼 디자인의 터치 피드백은 사용자가 UI 요소와 상호작용하는 시점에서 즉시 시각적으로 확인할 수 있습니다. 41 버튼의 기본 터치 피드백 애니메이션은 물결 효과를 통해 서로 다른 상태 간에 전환하는 새 {@link android.graphics.drawable.RippleDrawable} 클래스를 사용합니다. 42 43</p> 44 45<p>대부분의 경우, 다음과 같이 뷰 배경을 지정하는 방식으로 뷰 XML에서 이 기능을 적용해야 합니다. 46</p> 47 48<ul> 49<li>제한된 물결의 경우, <code>?android:attr/selectableItemBackground</code></li> 50<li>뷰를 넘어 확장되는 물결의 경우, <code>?android:attr/selectableItemBackgroundBorderless</code> 51 이 경우 물결이 null이 아닌 배경을 가진 뷰의 가장 가까운 상위 요소 위에 그려지고 해당 상위 요소까지로 제한됩니다. 52</li> 53</ul> 54 55<p class="note"><strong>참고:</strong> <code>selectableItemBackgroundBorderless</code>는 API 레벨 21에서 새로 도입된 특성입니다. 56</p> 57 58 59<p>또는 <code>ripple</code> 요소를 사용하여 {@link android.graphics.drawable.RippleDrawable} 60을 XML 리소스로 정의할 수 있습니다.</p> 61 62<p>{@link android.graphics.drawable.RippleDrawable} 객체에 색상을 지정할 수 있습니다. 기본 터치 피드백 색상을 변경하려면 테마의 <code>android:colorControlHighlight</code> 63특성을 사용합니다. 64</p> 65 66<p>자세한 내용은 {@link 67android.graphics.drawable.RippleDrawable} 클래스의 API 레퍼런스를 참조하세요.</p> 68 69 70<h2 id="Reveal">표시 효과 사용</h2> 71 72<p>표시 애니메이션은 UI 요소 그룹을 표시하거나 숨길 때 사용자에게 시각적 연속성을 제공합니다. 73 {@link android.view.ViewAnimationUtils#createCircularReveal 74ViewAnimationUtils.createCircularReveal()} 메서드를 사용하면 클리핑 서클을 애니메이트하여 뷰를 표시하거나 숨길 수 있습니다. 75</p> 76 77<p>이 효과를 사용하여 이전에 보이지 않았던 뷰를 표시하려면:</p> 78 79<pre> 80// previously invisible view 81View myView = findViewById(R.id.my_view); 82 83// get the center for the clipping circle 84int cx = (myView.getLeft() + myView.getRight()) / 2; 85int cy = (myView.getTop() + myView.getBottom()) / 2; 86 87// get the final radius for the clipping circle 88int finalRadius = Math.max(myView.getWidth(), myView.getHeight()); 89 90// create the animator for this view (the start radius is zero) 91Animator anim = 92 ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius); 93 94// make the view visible and start the animation 95myView.setVisibility(View.VISIBLE); 96anim.start(); 97</pre> 98 99<p>이 효과를 사용하여 이전에 보였던 뷰를 숨기려면:</p> 100 101<pre> 102// previously visible view 103final View myView = findViewById(R.id.my_view); 104 105// get the center for the clipping circle 106int cx = (myView.getLeft() + myView.getRight()) / 2; 107int cy = (myView.getTop() + myView.getBottom()) / 2; 108 109// get the initial radius for the clipping circle 110int initialRadius = myView.getWidth(); 111 112// create the animation (the final radius is zero) 113Animator anim = 114 ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, 0); 115 116// make the view invisible when the animation is done 117anim.addListener(new AnimatorListenerAdapter() { 118 @Override 119 public void onAnimationEnd(Animator animation) { 120 super.onAnimationEnd(animation); 121 myView.setVisibility(View.INVISIBLE); 122 } 123}); 124 125// start the animation 126anim.start(); 127</pre> 128 129 130<h2 id="Transitions">사용자지정 액티비티 전환</h2> 131 132<!-- shared transition video --> 133<div style="width:290px;margin-left:35px;float:right"> 134 <div class="framed-nexus5-port-span-5"> 135 <video class="play-on-hover" autoplay=""> 136 <source src="{@docRoot}design/material/videos/ContactsAnim.mp4"> 137 <source src="{@docRoot}design/material/videos/ContactsAnim.webm"> 138 <source src="{@docRoot}design/material/videos/ContactsAnim.ogv"> 139 </video> 140 </div> 141 <div style="font-size:10pt;margin-left:20px;margin-bottom:30px"> 142 <p class="img-caption" style="margin-top:3px;margin-bottom:10px"><strong>그림 1</strong> - 143 공유 요소를 이용한 전환.</p> 144 <em>영화를 재생하려면 기기 화면을 클릭하세요.</em> 145 </div> 146</div> 147 148<p>머티리얼 디자인 앱의 액티비티 전환은 공통 요소 간의 모션 및 변환을 통해 서로 다른 상태 간에 시각적 연결을 제공합니다. 149 들어가기 및 나가기 전환과 액티비티 간 공유 요소의 전환을 위한 사용자지정 애니메이션을 지정할 수 있습니다. 150</p> 151 152<ul> 153<li><strong>들어가기</strong> 전환은 액티비티에서 뷰가 장면 속으로 들어가는 방식을 결정합니다. 예를 들어, <em>explode</em> 들어가기 전환의 경우, 뷰가 밖에서 장면 속으로 들어가며 화면의 중앙으로 향합니다. 154 155</li> 156 157<li><strong>나가기</strong> 전환은 액티비티의 뷰가 장면을 나가는 방식을 결정합니다. 예를 들어, 나가기 전환으로 <em>explode</em>를 지정하면 뷰가 중앙에서부터 화면을 벗어납니다. 158 159</li> 160 161<li><strong>공유 요소</strong> 전환은 두 액티비티 간에 공유되는 뷰가 이 두 액티비티 간에 전환되는 방식을 결정합니다. 162 예를 들어 두 액티비티에서 사용하는 동일한 이미지가 다른 위치에 있고 크기도 다를 경우, <em>changeImageTransform</em> 공유 요소 전환은 두 액티비티 간에 이미지를 매끄럽게 변환하고 배율을 조정합니다. 163 164</li> 165</ul> 166 167<p>Android 5.0(API 레벨 21)은 다음 들어가기 및 나가기 전환을 지원합니다.</p> 168 169<ul> 170<li><em>explode</em> - 뷰를 장면의 중앙에서 안이나 밖으로 이동합니다.</li> 171<li><em>slide</em> - 뷰를 장면의 가장자리 중 하나에서 안이나 밖으로 이동합니다.</li> 172<li><em>fade</em> - 불투명도를 변경하여 뷰를 추가하거나 장면에서 제거합니다.</li> 173</ul> 174 175<p>{@link android.transition.Visibility} 클래스를 확장하는 모든 전환은 들어가기 또는 나가기 전환으로 지원됩니다. 176 자세한 내용은 177{@link android.transition.Transition} 클래스의 API 레퍼런스를 참조하세요.</p> 178 179<p>Android 5.0(API 레벨 21)은 다음의 공유 요소 전환도 지원합니다.</p> 180 181<ul> 182<li><em>changeBounds</em> - 대상 뷰의 레이아웃 경계에서 변경을 애니메이트합니다.</li> 183<li><em>changeClipBounds</em> - 대상 뷰의 클리핑 경계에서 변경을 애니메이트합니다.</li> 184<li><em>changeTransform</em> - 대상 뷰의 배율 및 회전 변경을 애니메이트합니다.</li> 185<li><em>changeImageTransform</em> - 대상 이미지의 크기 및 배율 변경을 애니메이트합니다.</li> 186</ul> 187 188<p>앱에서 액티비티 전환을 활성화할 경우, 들어가기 및 나가기 액티비티 간에 기본 크로스페이딩(cross-fading) 전환이 활성화됩니다. 189</p> 190 191<img src="{@docRoot}training/material/images/SceneTransition.png" alt="" width="600" height="405" style="margin-top:20px" /> 192<p class="img-caption"> 193 <strong>그림 2</strong> - 하나의 공유 요소로 장면 전환. 194</p> 195 196<h3>사용자지정 전환 지정</h3> 197 198<p>먼저 머티리얼 테마에서 상속하는 스타일을 정의할 때, <code>android:windowContentTransitions</code> 199특성을 통해 창 콘텐츠 전환을 활성화합니다. 들어가기, 나가기 및 공유 요소 전환도 스타일 정의에서 지정할 수 있습니다. 200</p> 201 202<pre> 203<style name="BaseAppTheme" parent="android:Theme.Material"> 204 <!-- enable window content transitions --> 205 <item name="android:windowContentTransitions">true</item> 206 207 <!-- specify enter and exit transitions --> 208 <item name="android:windowEnterTransition">@transition/explode</item> 209 <item name="android:windowExitTransition">@transition/explode</item> 210 211 <!-- specify shared element transitions --> 212 <item name="android:windowSharedElementEnterTransition"> 213 @transition/change_image_transform</item> 214 <item name="android:windowSharedElementExitTransition"> 215 @transition/change_image_transform</item> 216</style> 217</pre> 218 219<p>이 예에서 <code>change_image_transform</code> 전환은 다음과 같이 정의됩니다.</p> 220 221<pre> 222<!-- res/transition/change_image_transform.xml --> 223<!-- (see also Shared Transitions below) --> 224<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"> 225 <changeImageTransform/> 226</transitionSet> 227</pre> 228 229<p><code>changeImageTransform</code> 요소는 230{@link android.transition.ChangeImageTransform} 클래스에 해당합니다. 자세한 내용은 {@link android.transition.Transition}의 API 레퍼런스를 참조하세요. 231</p> 232 233<p>코드에서 창 콘텐츠 전환을 활성화하려면 234{@link android.view.Window#requestFeature Window.requestFeature()} 메서드를 호출합니다.</p> 235 236<pre> 237// inside your activity (if you did not enable transitions in your theme) 238getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); 239 240// set an exit transition 241getWindow().setExitTransition(new Explode()); 242</pre> 243 244<p>코드에서 전환을 지정하려면 {@link 245android.transition.Transition} 객체를 사용하여 다음과 같은 메서드를 호출합니다.</p> 246 247<ul> 248 <li>{@link android.view.Window#setEnterTransition Window.setEnterTransition()}</li> 249 <li>{@link android.view.Window#setExitTransition Window.setExitTransition()}</li> 250 <li>{@link android.view.Window#setSharedElementEnterTransition 251 Window.setSharedElementEnterTransition()}</li> 252 <li>{@link android.view.Window#setSharedElementExitTransition 253 Window.setSharedElementExitTransition()}</li> 254</ul> 255 256<p>{@link android.view.Window#setExitTransition setExitTransition()} 및 {@link 257android.view.Window#setSharedElementExitTransition setSharedElementExitTransition()} 메서드는 호출하는 액티비티의 나가기 전환을 정의합니다. 258 {@link android.view.Window#setEnterTransition 259setEnterTransition()} 및 {@link android.view.Window#setSharedElementEnterTransition 260setSharedElementEnterTransition()} 메서드는 호출되는 액티비티의 들어가기 전환을 정의합니다.</p> 261 262<p>전환 효과를 극대화하려면 호출하는 액티비티와 호출되는 액티비티 모두에서 창 콘텐츠 전환을 활성화해야 합니다. 263 그렇지 않으면 호출하는 액티비티가 나가기 전환을 시작하지만, 배율 또는 페이드와 같은 창 전환이 나타납니다. 264</p> 265 266<p>들어가기 전환을 최대한 빨리 시작하려면 호출되는 액티비티에서 267{@link android.view.Window#setAllowEnterTransitionOverlap Window.setAllowEnterTransitionOverlap()} 268 메서드를 사용하세요. 그러면 더욱 인상적인 들어가기 전환이 가능합니다.</p> 269 270<h3>전환을 사용하여 액티비티 시작</h3> 271 272<p>전환을 활성화하고 액티비티에 대해 나가기 전환을 설정한 경우, 다음과 같이 다른 액티비티를 시작하면 전환이 활성화됩니다. 273</p> 274 275<pre> 276startActivity(intent, 277 ActivityOptions.makeSceneTransitionAnimation(this).toBundle()); 278</pre> 279 280<p>두 번째 액티비티에 대해 들어가기 전환을 설정한 경우, 액티비티가 시작되면 전환도 활성화됩니다. 281 다른 액티비티를 시작할 때 전환을 비활성화하려면 <code>null</code> 옵션 번들을 제공하십시오. 282</p> 283 284<h3>공유 요소를 가진 액티비티 시작</h3> 285 286<p>공유 요소를 가진 두 액티비티 간에 화면 전환 애니메이션을 만들려면:</p> 287 288<ol> 289<li>테마에서 창 콘텐츠 전환을 활성화합니다.</li> 290<li>스타일에서 공유 요소 전환을 지정합니다.</li> 291<li>전환을 XML 리소스로 정의합니다.</li> 292<li> 293 <code>android:transitionName</code> 특성을 사용하여 두 레이아웃의 공유 요소에 공통 이름을 지정합니다.</li> 294<li>{@link android.app.ActivityOptions#makeSceneTransitionAnimation 295ActivityOptions.makeSceneTransitionAnimation()} 메서드를 사용합니다.</li> 296</ol> 297 298<pre> 299// get the element that receives the click event 300final View imgContainerView = findViewById(R.id.img_container); 301 302// get the common element for the transition in this activity 303final View androidRobotView = findViewById(R.id.image_small); 304 305// define a click listener 306imgContainerView.setOnClickListener(new View.OnClickListener() { 307 @Override 308 public void onClick(View view) { 309 Intent intent = new Intent(this, Activity2.class); 310 // create the transition animation - the images in the layouts 311 // of both activities are defined with android:transitionName="robot" 312 ActivityOptions options = ActivityOptions 313 .makeSceneTransitionAnimation(this, androidRobotView, "robot"); 314 // start the new activity 315 startActivity(intent, options.toBundle()); 316 } 317}); 318</pre> 319 320<p>코드에서 생성하는 공유된 동적 뷰의 경우, 321{@link android.view.View#setTransitionName View.setTransitionName()} 메서드를 사용하여 두 액티비티의 공통 요소 이름을 지정합니다. 322</p> 323 324<p>두 번째 액티비티 종료 시, 장면 전환 애니메이션을 되돌리려면 {@link android.app.Activity#finish Activity.finish()} 대신 325{@link android.app.Activity#finishAfterTransition Activity.finishAfterTransition()} 326 메서드를 호출합니다.</p> 327 328<h3>여러 공유 요소를 가진 액티비티 시작</h3> 329 330<p>2개 이상의 공유 요소를 가진 두 액티비티 간에 적용할 장면 전환 애니메이션을 만들려면 <code>android:transitionName</code> 331특성으로 (또는 두 액티비티에서{@link android.view.View#setTransitionName View.setTransitionName()} 메서드를 사용하여) 두 레이아웃의 공유 요소를 정의하고 다음과 같이 {@link android.app.ActivityOptions} 개체를 생성합니다. 332 333</p> 334 335<pre> 336ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, 337 Pair.create(view1, "agreedName1"), 338 Pair.create(view2, "agreedName2")); 339</pre> 340 341 342<h2 id="CurvedMotion">커브 모션 사용</h2> 343 344<p>머티리얼 디자인의 애니메이션은 시간 보간 및 공간 이동 패턴에서 커브를 사용합니다. 345 Android 5.0(API 레벨 21) 이상에서 애니메이션의 사용자지정 타이밍 커브 및 커브 모션 패턴을 정의할 수 있습니다. 346</p> 347 348<p>{@link android.view.animation.PathInterpolator} 클래스는 베지어 곡선 또는 {@link android.graphics.Path} 개체를 기반으로 하는 새 보간기입니다. 349 이 보간기는 생성자 인수를 사용하여 지정된 기준점 (0,0) 및 (1,1)과 제어점으로 모션 커브를 1x1 정사각형 안에 지정합니다. 350 351 또한 경로 보간기를 XML 리소스로 정의할 수도 있습니다.</p> 352 353<pre> 354<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" 355 android:controlX1="0.4" 356 android:controlY1="0" 357 android:controlX2="1" 358 android:controlY2="1"/> 359</pre> 360 361<p>시스템은 머티리얼 디자인 사양에서 세 가지 기본 커브에 대한 XML 리소스를 제공합니다. 362</p> 363 364<ul> 365 <li><code>@interpolator/fast_out_linear_in.xml</code></li> 366 <li><code>@interpolator/fast_out_slow_in.xml</code></li> 367 <li><code>@interpolator/linear_out_slow_in.xml</code></li> 368</ul> 369 370<p>{@link android.view.animation.PathInterpolator} 객체를 {@link 371android.animation.Animator#setInterpolator Animator.setInterpolator()} 메서드에 전달할 수 있습니다.</p> 372 373<p>{@link android.animation.ObjectAnimator} 클래스에는 한 번에 2개 이상의 속성을 사용하여 경로를 따라 좌표를 애니메이트할 수 있는 새 생성자가 있습니다. 374 예를 들어 다음 애니메이터는 뷰의 X 및 Y 속성을 애니메이트하기 위해 {@link android.graphics.Path} 객체를 사용합니다. 375</p> 376 377<pre> 378ObjectAnimator mAnimator; 379mAnimator = ObjectAnimator.ofFloat(view, View.X, View.Y, path); 380... 381mAnimator.start(); 382</pre> 383 384 385<h2 id="ViewState">뷰 상태 변경 애니메이트</h2> 386 387<p>{@link android.animation.StateListAnimator} 클래스를 사용하면 뷰의 상태가 변경될 때 실행되는 애니메이터를 정의할 수 있습니다. 388 다음 예는 {@link 389android.animation.StateListAnimator}를 XML 리소스로 정의하는 방법을 보여줍니다.</p> 390 391<pre> 392<!-- animate the translationZ property of a view when pressed --> 393<selector xmlns:android="http://schemas.android.com/apk/res/android"> 394 <item android:state_pressed="true"> 395 <set> 396 <objectAnimator android:propertyName="translationZ" 397 android:duration="@android:integer/config_shortAnimTime" 398 android:valueTo="2dp" 399 android:valueType="floatType"/> 400 <!-- you could have other objectAnimator elements 401 here for "x" and "y", or other properties --> 402 </set> 403 </item> 404 <item android:state_enabled="true" 405 android:state_pressed="false" 406 android:state_focused="true"> 407 <set> 408 <objectAnimator android:propertyName="translationZ" 409 android:duration="100" 410 android:valueTo="0" 411 android:valueType="floatType"/> 412 </set> 413 </item> 414</selector> 415</pre> 416 417<p>사용자지정 뷰 상태 애니메이션을 뷰에 첨부하려면 이 예와 같이 XML 리소스 파일의 418<code>selector</code> 요소를 사용하여 애니메이터를 정의한 후에 <code>android:stateListAnimator</code> 특성을 통해 뷰에 할당합니다. 419 코드에서 뷰에 상태 목록 애니메이터를 할당하려면 {@link android.animation.AnimatorInflater#loadStateListAnimator 420AnimationInflater.loadStateListAnimator()} 메서드를 사용하고, 421{@link android.view.View#setStateListAnimator View.setStateListAnimator()} 메서드로 애니메이터를 뷰에 할당합니다. 422</p> 423 424<p>머티리얼 테마를 확장하는 테마의 경우, 버튼은 기본적으로 Z 애니메이션을 가집니다. 버튼에서 이러한 동작을 피하려면 <code>android:stateListAnimator</code> 특성을 425<code>@null</code>로 설정합니다. 426</p> 427 428<p>{@link android.graphics.drawable.AnimatedStateListDrawable} 클래스를 사용하면 연관된 뷰의 상태 변경 사이에 애니메이션을 보여주는 Drawable을 생성할 수 있습니다. 429 Android 5.0의 일부 시스템 위젯은 이러한 애니메이션을 기본적으로 사용합니다. 430 다음 예는 {@link android.graphics.drawable.AnimatedStateListDrawable}를 XML 리소스로 정의하는 방법을 보여줍니다. 431</p> 432 433<pre> 434<!-- res/drawable/myanimstatedrawable.xml --> 435<animated-selector 436 xmlns:android="http://schemas.android.com/apk/res/android"> 437 438 <!-- provide a different drawable for each state--> 439 <item android:id="@+id/pressed" android:drawable="@drawable/drawableP" 440 android:state_pressed="true"/> 441 <item android:id="@+id/focused" android:drawable="@drawable/drawableF" 442 android:state_focused="true"/> 443 <item android:id="@id/default" 444 android:drawable="@drawable/drawableD"/> 445 446 <!-- specify a transition --> 447 <transition android:fromId="@+id/default" android:toId="@+id/pressed"> 448 <animation-list> 449 <item android:duration="15" android:drawable="@drawable/dt1"/> 450 <item android:duration="15" android:drawable="@drawable/dt2"/> 451 ... 452 </animation-list> 453 </transition> 454 ... 455</animated-selector> 456</pre> 457 458 459<h2 id="AnimVector">벡터 드로어블 애니메이트</h2> 460 461<p><a href="{@docRoot}training/material/drawables.html#VectorDrawables">벡터 드로어블</a>은 정의를 잃지 않고 확대할 수 있습니다. 462 {@link android.graphics.drawable.AnimatedVectorDrawable} 463클래스를 사용하면 Vector Drawable의 속성을 애니메이트할 수 있습니다.</p> 464 465<p>일반적으로 애니메이트된 벡터 드로어블은 다음 3개의 XML 파일에서 정의합니다.</p> 466 467<ul> 468<li> 469<code>res/drawable/</code>의 <code><vector></code> 요소를 가진 벡터 드로어블</li> 470<li> 471<code>res/drawable/</code>의 <code><animated-vector></code> 요소를 가진 애니메이트된 벡터 드로어블</li> 472<li> 473<code>res/anim/</code>의 <code><objectAnimator></code> 요소를 가진 하나 이상의 객체 애니메이터</li> 474</ul> 475 476<p>애니메이트된 벡터 드로어블은 <code><group></code> 및 477<code><path></code> 요소의 특성을 애니메이트할 수 있습니다. <code><group></code> 요소는 경로 또는 하위 그룹 집합을 정의하며, <code><path></code> 요소는 그릴 경로를 정의합니다. 478</p> 479 480<p>애니메이트할 벡터 드로어블을 정의하는 경우, 애니메이터 정의에서 참조할 수 있도록 <code>android:name</code> 481특성을 사용하여 그룹 및 경로에 고유한 이름을 할당합니다. 482 예:</p> 483 484<pre> 485<!-- res/drawable/vectordrawable.xml --> 486<vector xmlns:android="http://schemas.android.com/apk/res/android" 487 android:height="64dp" 488 android:width="64dp" 489 android:viewportHeight="600" 490 android:viewportWidth="600"> 491 <group 492 <strong>android:name="rotationGroup"</strong> 493 android:pivotX="300.0" 494 android:pivotY="300.0" 495 android:rotation="45.0" > 496 <path 497 <strong>android:name="v"</strong> 498 android:fillColor="#000000" 499 android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" /> 500 </group> 501</vector> 502</pre> 503 504<p>애니메이트된 벡터 드로어블 정의는 벡터 드로어블의 그룹 및 경로를 이름으로 참조합니다. 505</p> 506 507<pre> 508<!-- res/drawable/animvectordrawable.xml --> 509<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" 510 android:drawable="@drawable/vectordrawable" > 511 <target 512 android:name="rotationGroup" 513 android:animation="@anim/rotation" /> 514 <target 515 android:name="v" 516 android:animation="@anim/path_morph" /> 517</animated-vector> 518</pre> 519 520<p>애니메이션 정의는 {@link android.animation.ObjectAnimator} 또는 {@link 521android.animation.AnimatorSet} 객체를 나타냅니다. 이 예의 첫 번째 애니메이터는 대상 그룹을 360도 회전합니다. 522</p> 523 524<pre> 525<!-- res/anim/rotation.xml --> 526<objectAnimator 527 android:duration="6000" 528 android:propertyName="rotation" 529 android:valueFrom="0" 530 android:valueTo="360" /> 531</pre> 532 533<p>두 번째 애니메이터는 벡터 드로어블의 경로를 다른 모양으로 모핑합니다. 534 두 경로 모두 모핑이 가능해야 하며, 같은 수의 명령어와 각 명령어에 대해 같은 수의 매개변수가 있어야 합니다. 535</p> 536 537<pre> 538<!-- res/anim/path_morph.xml --> 539<set xmlns:android="http://schemas.android.com/apk/res/android"> 540 <objectAnimator 541 android:duration="3000" 542 android:propertyName="pathData" 543 android:valueFrom="M300,70 l 0,-70 70,70 0,0 -70,70z" 544 android:valueTo="M300,70 l 0,-70 70,0 0,140 -70,0 z" 545 android:valueType="pathType" /> 546</set> 547</pre> 548 549<p>자세한 내용은 {@link 550android.graphics.drawable.AnimatedVectorDrawable}의 API 레퍼런스를 참조하세요.</p> 551