Add examples of animator resource files to ApiDemos
Issue #17939329 Expose multi-property and multi-keyframe capabilities in animation resources Change-Id: If5b66b054b132b34c56b921209835793c7bbe674
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- BEGIN_INCLUDE(ValueAnimatorResources) -->
|
||||||
<animator xmlns:android="http://schemas.android.com/apk/res/android"
|
<animator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:duration="1000"
|
android:duration="1000"
|
||||||
android:valueFrom="1"
|
android:valueFrom="1"
|
||||||
@@ -21,3 +22,4 @@
|
|||||||
android:valueType="floatType"
|
android:valueType="floatType"
|
||||||
android:repeatCount="1"
|
android:repeatCount="1"
|
||||||
android:repeatMode="reverse"/>
|
android:repeatMode="reverse"/>
|
||||||
|
<!-- END_INCLUDE(ValueAnimatorResources) -->
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- BEGIN_INCLUDE(ObjectAnimatorResources) -->
|
||||||
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:duration="1000"
|
android:duration="1000"
|
||||||
android:valueTo="200"
|
android:valueTo="200"
|
||||||
@@ -21,3 +22,4 @@
|
|||||||
android:propertyName="y"
|
android:propertyName="y"
|
||||||
android:repeatCount="1"
|
android:repeatCount="1"
|
||||||
android:repeatMode="reverse"/>
|
android:repeatMode="reverse"/>
|
||||||
|
<!-- END_INCLUDE(ObjectAnimatorResources) -->
|
||||||
|
|||||||
25
samples/ApiDemos/res/anim/object_animator_pvh.xml
Normal file
25
samples/ApiDemos/res/anim/object_animator_pvh.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2015 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- BEGIN_INCLUDE(PropertyValuesHolderResources) -->
|
||||||
|
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:duration="1000"
|
||||||
|
android:repeatCount="1"
|
||||||
|
android:repeatMode="reverse">
|
||||||
|
<propertyValuesHolder android:propertyName="x" android:valueTo="400"/>
|
||||||
|
<propertyValuesHolder android:propertyName="y" android:valueTo="200"/>
|
||||||
|
</objectAnimator>
|
||||||
|
<!-- END_INCLUDE(PropertyValuesHolderResources) -->
|
||||||
33
samples/ApiDemos/res/anim/object_animator_pvh_kf.xml
Normal file
33
samples/ApiDemos/res/anim/object_animator_pvh_kf.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2015 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:duration="1000"
|
||||||
|
android:repeatCount="1"
|
||||||
|
android:repeatMode="reverse">
|
||||||
|
<!-- BEGIN_INCLUDE(KeyframeResources) -->
|
||||||
|
<propertyValuesHolder android:propertyName="x" >
|
||||||
|
<keyframe android:fraction="0" android:value="800" />
|
||||||
|
<keyframe android:fraction=".2" android:value="1000" />
|
||||||
|
<keyframe android:fraction="1" android:value="400" />
|
||||||
|
</propertyValuesHolder>
|
||||||
|
<propertyValuesHolder android:propertyName="y" >
|
||||||
|
<keyframe/>
|
||||||
|
<keyframe android:value="300" />
|
||||||
|
<keyframe android:value="1000" />
|
||||||
|
</propertyValuesHolder>
|
||||||
|
<!-- END_INCLUDE(KeyframeResources) -->
|
||||||
|
</objectAnimator>
|
||||||
28
samples/ApiDemos/res/anim/value_animator_pvh_kf.xml
Normal file
28
samples/ApiDemos/res/anim/value_animator_pvh_kf.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2015 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- BEGIN_INCLUDE(ValueAnimatorKeyframeResources) -->
|
||||||
|
<animator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:duration="1000"
|
||||||
|
android:repeatCount="1"
|
||||||
|
android:repeatMode="reverse">
|
||||||
|
<propertyValuesHolder>
|
||||||
|
<keyframe android:fraction="0" android:value="1"/>
|
||||||
|
<keyframe android:fraction=".2" android:value=".4"/>
|
||||||
|
<keyframe android:fraction="1" android:value="0"/>
|
||||||
|
</propertyValuesHolder>
|
||||||
|
</animator>
|
||||||
|
<!-- END_INCLUDE(ValueAnimatorKeyframeResources) -->
|
||||||
@@ -78,6 +78,9 @@ public class AnimationLoading extends Activity {
|
|||||||
addBall(200, 50);
|
addBall(200, 50);
|
||||||
addBall(350, 50);
|
addBall(350, 50);
|
||||||
addBall(500, 50, Color.GREEN);
|
addBall(500, 50, Color.GREEN);
|
||||||
|
addBall(650, 50);
|
||||||
|
addBall(800, 50);
|
||||||
|
addBall(950, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAnimation() {
|
private void createAnimation() {
|
||||||
@@ -106,8 +109,27 @@ public class AnimationLoading extends Activity {
|
|||||||
loadAnimator(appContext, R.anim.color_animator);
|
loadAnimator(appContext, R.anim.color_animator);
|
||||||
colorizer.setTarget(balls.get(3));
|
colorizer.setTarget(balls.get(3));
|
||||||
|
|
||||||
|
ObjectAnimator animPvh = (ObjectAnimator) AnimatorInflater.
|
||||||
|
loadAnimator(appContext, R.anim.object_animator_pvh);
|
||||||
|
animPvh.setTarget(balls.get(4));
|
||||||
|
|
||||||
|
|
||||||
|
ObjectAnimator animPvhKf = (ObjectAnimator) AnimatorInflater.
|
||||||
|
loadAnimator(appContext, R.anim.object_animator_pvh_kf);
|
||||||
|
animPvhKf.setTarget(balls.get(5));
|
||||||
|
|
||||||
|
ValueAnimator faderKf = (ValueAnimator) AnimatorInflater.
|
||||||
|
loadAnimator(appContext, R.anim.value_animator_pvh_kf);
|
||||||
|
faderKf.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||||
|
public void onAnimationUpdate(ValueAnimator animation) {
|
||||||
|
balls.get(6).setAlpha((Float) animation.getAnimatedValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
animation = new AnimatorSet();
|
animation = new AnimatorSet();
|
||||||
((AnimatorSet) animation).playTogether(anim, fader, seq, colorizer);
|
((AnimatorSet) animation).playTogether(anim, fader, seq, colorizer, animPvh,
|
||||||
|
animPvhKf, faderKf);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user