DevBytes: Property Animations

Android Developers · 36K views · 2013 · 8:26

Open on YouTube

Software practice, open source & careersSoftware (other)tutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering questions about ObjectAnimator, property animation and the difference from older view animations, as a clear first-party walkthrough.

Recommended by 6 people across 6 different months, 2013 to 2018.

What it is

A short Android Developers DevBytes episode that shows how to use property animations, mainly ObjectAnimator, to animate views. It compares this with the pre-3.0 view animation APIs shown in a companion ViewAnimations demo, and comes with downloadable sample code. Chet Haase of Google presents it.

What people said

Strong rec A Honey Bustard · 2015-03 · Stack Overflow · on “ObjectAnimator vs TranslateAnimation”

The difference is mainly that if you use a TranslateAnimation, the view which you are animating does not really leave its original position on the screen, it just makes it look like it is moving. So the view basically doesnt change its coordinates. Check this video about View Animations : [LINK] If you use an ObjectAnimator the view really changes its actual position. TranslateAnimation is not deprecated, you can still find it on Lollipop, but for most cases I can recommend a class called ViewPropertyAnimator [LINK] , which many people still dont seem to know about, it is probably the easiest and most straight forward way to animate a view, and can also save you a lot of code. Heres an examp

Recommends nhaarman · 2013-05 · Stack Overflow · on “How to modify an animated view while it is animated?”

I'd recommend to use the new Property Animations [LINK] . If you need to support API's < 11 you can check out the Nine Old Androids [LINK] library. See [this video] for a nice explanation from Chet Haase about this.

Recommends ysnsyhn · 2015-05 · Stack Overflow · on “Hiding and showing multiple views using the same animation”

You may use object animators. There is an easy example in that link [LINK] which you can also use. You may also use this tutorial [this video] .

Recommends Sergey Shustikov · 2015-07 · Stack Overflow · on “Android: How to make animation starting from the last position?”

If setFillAfter(boolean filled) not works you can use a Property [LINK] animations. They change layout parameters, so you can start animation after she ends from the last position. Also look this video [this video] .

Recommends Rosário P. Fernandes · 2017-01 · Stack Overflow · on “Firebase on app startup taking more than 3 seconds to load data”

As Doug Stevenson said: there should be a little delay when you're loading data for the first time, or if you're in a part of the world that is different than where the Firebase services happen to be hosted. I suggest you create a loading screen (splash screen) to load all the data before showing your Main Activity. In this Loading Activity, you can load all the data using the keepSynced method: FirebaseDatabase.getInstance().getReference().keepSynced(true); This method will download your whole database to the disk cache. And when you show your Main Activity, FIrebase will load the data from this cache. Generally, loading screens stay on screen for 1000-1500 milliseconds. But since you're sa

Recommends Klodian Kambo · 2017-11 · Stack Overflow · on “ObjectAnimator with scale property makes bg black?”

As stated in the comments, the approach for creating an ObjectAnimator [LINK] is to use the View's static Property [LINK] object instead of passing the string since using the string value involves reflection for the setter and optionally for the getter in order to derive the starting value of the attribute. This is available from API 14 [LINK] ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, View.SCALE_X, 0.5f); ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.5f); A complete explanation can be found in DevBytes: Property Animations [this video] video by Google's engineer Chet Haase

Cites Hrafn · 2013-04 · Stack Overflow · on “What kind of value does android:valueTo represent”

From what I've been able to gather from blog posts [LINK] and videos [this video] , it would seem that the values that objectAnimator properties can take vary between properties. For instance, scale represents percentage scaling, so value 2 represents 200%. And translationX uses dp, so 2 and 300 are both in dp. Thus usage of %, %p or dp, as was possible in animation sets prior to Android 3.1, doesn't seem to be possible in the new framework.

Cites Xaver Kapeller · 2014-06 · Stack Overflow · on “How to define a screen-size specific animation in XML”

1) Regarding the bounty: Existing answers on SO [LINK] suggest subclassing the FrameLayout... If you want to use an ObjectAnimator you have no choice but to subclass the View you want to animate. You need to provide the ObjectAnimator with the necessary getter and setter methods to do its magic as it essentially just calls those getter and setter methods to perform the Animation . The question you are linking to ( Animate the transition between fragments [LINK] ) is subclassing FrameLayout to add a setXFraction() and a getXFraction() method. They are implemented in a way to set the x value relative to the width of the FrameLayout . Only by doing this can the ObjectAnimator do anything else b

Cites cjayem13 · 2014-10 · Stack Overflow · on “When code requires an certain API level, why must the check for Build.Version be the same required rather than at or above the required level?”

I was watching an android developers video ( [this video] ) on property animations when I ran into a problem that's easy to fix but difficult for me to understand and was hoping someone could shine some light on it for me.. I have a project that is targeting API level 8 in the manifest so when I used the code below I got an error stating that the code used requires a higher API level than the currently targeted API level. As a work around I checked for the Build version at runtime ( [LINK] ) and only ran the code segment if the API level sufficed. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(resp1, View.ROTATION, 27

Cites YaZao RuZakiaga · 2018-07 · Stack Overflow · on “Slide Right to Left using ObjectAnimation”

I can do the slide left to right thanks to the sample code given in this YouTube link: [this video] However I can't do the right to left animation. What I've tried is putting a '-' (negative) sign in the code below but it wont work and it gives me the error: Operator '-' cannot be applied to 'android.util.Property ObjectAnimator translateAnimation = ObjectAnimator.ofFloat(view, -View.TRANSLATION_X, 800); translateAnimation.start(); translateAnimation.setRepeatCount(1); translateAnimation.setRepeatMode(ValueAnimator.REVERSE); Any way to do this inside an Activity?