<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"]/>
好的,我正在学习 Android 中的一些动画。我从 Google 开发者文档中找到了两个属性,但实际上我无法理解它们的含义。
android:propertyName="string"
android:valueType=["intType" | "floatType"]
有些值是有意义的, 如"fade", "rotation", "alpha"
,但像endYear, firstDayOfWeek
这样的其他值呢?我无法找到任何详细的文档解释这些问题,或者也许是因为我没有理解各种教程和谷歌文档试图传达的内容。
**
我的疑问是如何获取所有可能的
"propertyName"
的值,以及"valueType"
是什么意思,我指它实际上是做什么的,它如何影响动画
**
我在参考这个教程,并尝试使用属性来更好地理解。例如下面的屏幕截图展示了propertyName
的许多可能性,但我不知道它们是什么意思。
此外,propertyName
接受"x"和"y"作为其值,但它们在窗口中并不存在。
至于ValueType
,如果我在下面这个教程中更改"wheel"
的floatType为"intType"
<objectAnimator
android:duration="3000"
android:propertyName="rotation"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueTo="180"
android:valueType="floatType" />
它停止动画了..??????
有人能解释这个问题或提供一个资源,以便我可以找出原因。
这就是在Google文档中所解释的内容。
注意:这不仅是我第一次尝试在Android上进行动画,也是我生命中第一次尝试动画。
android:propertyName="x"
时,它实际上会查找getX()
,这可能在源代码中预定义了,但是当我写android:propertyName="z"
时,它会引发错误Method setZ() with type int not found on target class class android.widget.ImageView
,这意味着如果我自己定义getZ()
,它就会自动开始选择它。是吗?但是当我查看android.widget.ImageView
的源代码时,甚至看不到像setX()
这样的东西,尽管它接受"x"
作为属性名称。 - DeltaCap019setX()
方法 是在 Android.view.View 类 中添加的,要求 API 11 (Honeycomb) 及以上版本。 - JoeImageView
,但是根据生成的错误“在 android.widget.ImageView 上找不到方法”,我跳转到了它的源代码,并感到更加困惑...你提供的链接有助于从中获取更有意义的信息 :) - DeltaCap019PropertyName
很清楚了。 那么ValueType
呢?根据自动完成窗口,它只能是int
和float
。这是否告诉我们要传递给PropertyName
方法的argument type
。我的理解是,提供ValueType
是为了支持Mehtod Overloading
。如果我们有一个接受int
参数和另一个接受float
参数的相同方法,则ValueType
有助于指定调用哪个方法。我是对的吗? - DeltaCap019