Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e7c7a2a authored by Robert Ly's avatar Robert Ly
Browse files

cherrypick from hc-mr2 Change-Id: I06f5abf8bb956e96963d47f3fa41bfe1ea8d1c7b

Change-Id: I37fb07126676737d16294e64ac974c0da39a3b05
parent 070ce94b
Loading
Loading
Loading
Loading
+76 −32
Original line number Diff line number Diff line
@@ -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>
@@ -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>