Android Property Animation
Asked Answered
M

2

11
<objectAnimator
    android:propertyName="string"
    android:duration="int"
    android:valueFrom="float | int | color"
    android:valueTo="float | int | color"
    android:startOffset="int"
    android:repeatCount="int"
    android:repeatMode=["repeat" | "reverse"]
    android:valueType=["intType" | "floatType"]/>

Ok I am learning some Animation in android. I got it from Google Developer Docs two attributes that actually I am not able to understand are

android:propertyName="string"
android:valueType=["intType" | "floatType"]

Some of the values make sense "fade", "rotation", "alpha" But what about others like endYear, firstDayOfWeek

And I failed to find any detailed documentation about these or there may be chances that I am not understanding what various tutorials and Google Docs trying to convey..

**

My doubt is from where I can get all possible values of "propertyName" And what is "valueType" I mean what actually it do how actually it affect the animation

**

I am following this Tutorial and was trying to play with properties so as to have better understanding.

For say below attached screenshot shows so many possibilities for propertyName but I dont know how they make sense.

enter image description here

More Over propertyName accepts "x" and "y" as it values but they don't come in the window.

In case of ValueType if I change "floatType" to "intType" in the below mention snippet of the tutorial for wheel

<objectAnimator
    android:duration="3000"
        android:propertyName="rotation"
        android:repeatCount="infinite"
        android:repeatMode="reverse"
        android:valueTo="180"
        android:valueType="floatType" />

It stops animating..??????

Can Any one explain this issue or a source so as that I can figure it out..

This is what is explained in Google docs

NOTE:- I am trying animation for the first time not only with android but in my life too...

Mossgrown answered 25/6, 2013 at 10:53 Comment(0)
S
12

The propertyName parameter can be any property defined by the animation target's class. For instance, if the object you're animating offer a getFoo() and a setFoo() method, then there is a "foo" property you can animate.

A very simple example is View's getAlpha() and setAlpha() methods. They defined together the "alpha" property that you can animate to create fading effects

This also means you can create your own properties in your custom views. All you need to do is create two public methods: a getter and a setter.

You can look at this page for more information: http://developer.android.com/guide/topics/graphics/prop-animation.html#object-animator

Seigel answered 1/7, 2013 at 22:38 Comment(4)
Ok I got a better understanding now regarding the concept behind it.. It means when I write android:propertyName="x" it looks for getX() actually which may be predefined somewhere in Source, but when I wirte android:propertyName="z" it raises error Method setZ() with type int not found on target class class android.widget.ImageView that means if I will define getZ() on my own then it will start picking it automatically.. isn't it??? But when i looked at the source code of android.widget.ImageView i cant see even something like setX() although it accepts "x" as propertyname.Mossgrown
@AbhinavRathore you might not be looking at the correct file/version of the source code. The setX() method is added to the android.view.View class on API 11 (Honeycomb).Eventuate
@Eventuate hmm you caught it right I was looking into github.com/android/platform_frameworks_base/blob/master/core/… as I was applying animation properties to ImageView and according to the error generated method not found on android.widget.ImageView I jumped into its Source Code and got more confused... Your link is helpful to bring out more meaning full things from it :)Mossgrown
I am clear about PropertyName now. What about ValueType? As it can be only int and float according to auto-completion window Does it tells the argument type to be passed to the PropertyName method. What I am getting it as is it ValueType is provided so as to provide support for Mehtod Overloading. If we have same method one accepting int arguments other float arguments then ValueType helps in specifying which one to call. Am I right??Mossgrown
T
9

for honeycomb and above the available ones (according to this website) are:

  • translationX
  • translationY
  • rotation
  • rotationX
  • rotationY
  • scaleX
  • scaleY
  • pivotX
  • pivotY
  • x
  • y
  • alpha

as mentioned, you can also create your own properties, using get&set . i wonder if the new android versions have more properties built in.

you can also test them out in the API demos , in nineOldAndroids library , and on one of samsung samples.

Turbine answered 17/7, 2013 at 20:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.