Loading docs/html/guide/topics/graphics/animation.jd +76 −32 Original line number Diff line number Diff line Loading @@ -28,9 +28,14 @@ parent.link=index.html <li><a href="#interpolators">Using Interpolators</a></li> <li><a href="#keyframes">Specifying Keyframes</a></li> <li><a href="#layout">Animating Layout Changes to ViewGroups</a></li> <li><a href="#views">Animating Views</a></li> <li><a href="#views">Animating Views</a> <ol> <li><a href="#view-prop-animator">ViewPropertyAnimator</a></li> </ol> </li> <li><a href="#declaring-xml">Declaring Animations in XML</a></li> </ol> Loading Loading @@ -872,9 +877,48 @@ rotationAnim.setDuration(5000ms); ObjectAnimator.ofFloat(myView, "rotation", 0f, 360f); </pre> For more information on creating animators, see the sections on animating with <a href="#value-animator">ValueAnimator</a> and <a href="#object-animator">ObjectAnimator</a> <p>For more information on creating animators, see the sections on animating with <a href="#value-animator">ValueAnimator</a> and <a href="#object-animator">ObjectAnimator</a>. </p> <h3 id="view-prop-animator">Animating with ViewPropertyAnimator</h3> <p>The {@link android.view.ViewPropertyAnimator} provides a simple way to animate several properties of a {@link android.view.View} in parallel, using a single underlying {@link android.animation.Animator} object. It behaves much like an {@link android.animation.ObjectAnimator}, because it modifies the actual values of the view's properties, but is more efficient when animating many properties at once. In addition, the code for using the {@link android.view.ViewPropertyAnimator} is much more concise and easier to read. The following code snippets show the differences in using multiple {@link android.animation.ObjectAnimator} objects, a single {@link android.animation.ObjectAnimator}, and the {@link android.view.ViewPropertyAnimator} when simultaneously animating the <code>x</code> and <code>y</code> property of a view.</p> <p><strong>Multiple ObjectAnimator objects</strong></p> <pre> ObjectAnimator animX = ObjectAnimator.ofFloat(myView, "x", 50f); ObjectAnimator animY = ObjectAnimator.ofFloat(myView, "y", 100f); AnimatorSet animSetXY = new AnimatorSet(); animSetXY.playTogether(animX, animY); animSetXY.start(); </pre> <p><strong>One ObjectAnimator</strong></p> <pre> PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 50f); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 100f); ObjectAnimator.ofPropertyValuesHolder(myView, pvhX, pvyY).start(); </pre> <p><strong>ViewPropertyAnimator</strong></p> <pre> myView.animate().x(50f).y(100f); </pre> <p> For more detailed information about {@link android.view.ViewPropertyAnimator}, see the corresponding Android Developers <a href="http://android-developers.blogspot.com/2011/05/introducing-viewpropertyanimator.html">blog post</a>.</p> <h2 id="declaring-xml">Declaring Animations in XML</h2> Loading Loading
docs/html/guide/topics/graphics/animation.jd +76 −32 Original line number Diff line number Diff line Loading @@ -28,9 +28,14 @@ parent.link=index.html <li><a href="#interpolators">Using Interpolators</a></li> <li><a href="#keyframes">Specifying Keyframes</a></li> <li><a href="#layout">Animating Layout Changes to ViewGroups</a></li> <li><a href="#views">Animating Views</a></li> <li><a href="#views">Animating Views</a> <ol> <li><a href="#view-prop-animator">ViewPropertyAnimator</a></li> </ol> </li> <li><a href="#declaring-xml">Declaring Animations in XML</a></li> </ol> Loading Loading @@ -872,9 +877,48 @@ rotationAnim.setDuration(5000ms); ObjectAnimator.ofFloat(myView, "rotation", 0f, 360f); </pre> For more information on creating animators, see the sections on animating with <a href="#value-animator">ValueAnimator</a> and <a href="#object-animator">ObjectAnimator</a> <p>For more information on creating animators, see the sections on animating with <a href="#value-animator">ValueAnimator</a> and <a href="#object-animator">ObjectAnimator</a>. </p> <h3 id="view-prop-animator">Animating with ViewPropertyAnimator</h3> <p>The {@link android.view.ViewPropertyAnimator} provides a simple way to animate several properties of a {@link android.view.View} in parallel, using a single underlying {@link android.animation.Animator} object. It behaves much like an {@link android.animation.ObjectAnimator}, because it modifies the actual values of the view's properties, but is more efficient when animating many properties at once. In addition, the code for using the {@link android.view.ViewPropertyAnimator} is much more concise and easier to read. The following code snippets show the differences in using multiple {@link android.animation.ObjectAnimator} objects, a single {@link android.animation.ObjectAnimator}, and the {@link android.view.ViewPropertyAnimator} when simultaneously animating the <code>x</code> and <code>y</code> property of a view.</p> <p><strong>Multiple ObjectAnimator objects</strong></p> <pre> ObjectAnimator animX = ObjectAnimator.ofFloat(myView, "x", 50f); ObjectAnimator animY = ObjectAnimator.ofFloat(myView, "y", 100f); AnimatorSet animSetXY = new AnimatorSet(); animSetXY.playTogether(animX, animY); animSetXY.start(); </pre> <p><strong>One ObjectAnimator</strong></p> <pre> PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 50f); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 100f); ObjectAnimator.ofPropertyValuesHolder(myView, pvhX, pvyY).start(); </pre> <p><strong>ViewPropertyAnimator</strong></p> <pre> myView.animate().x(50f).y(100f); </pre> <p> For more detailed information about {@link android.view.ViewPropertyAnimator}, see the corresponding Android Developers <a href="http://android-developers.blogspot.com/2011/05/introducing-viewpropertyanimator.html">blog post</a>.</p> <h2 id="declaring-xml">Declaring Animations in XML</h2> Loading