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...

ColdFire
  • 6,764
  • 6
  • 35
  • 51
DeltaCap019
  • 6,532
  • 3
  • 48
  • 70

2 Answers2

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

Romain Guy
  • 97,993
  • 18
  • 219
  • 200
  • 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. – DeltaCap019 Jul 02 '13 at 04:35
  • 3
    @AbhinavRathore you might not be looking at the correct file/version of the source code. The [`setX()` method](http://developer.android.com/reference/android/view/View.html#setX(float)) is added to the [android.view.View class](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/View.java) on [API 11 (Honeycomb)](http://developer.android.com/sdk/api_diff/11/changes.html). – Joe Jul 02 '13 at 20:25
  • 1
    @Joe hmm you caught it right I was looking into https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/ImageView.java 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 :) – DeltaCap019 Jul 03 '13 at 04:33
  • 2
    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?? – DeltaCap019 Jul 03 '13 at 04:54
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.

android developer
  • 114,585
  • 152
  • 739
  • 1,270