如何在xml anim文件中指定fromXType属性

时间:2012-09-04 14:06:25

标签: android xml animation

我想在xml和代码中制作相同的动画。 我编码我有这个

    Animation a = new TranslateAnimation(Animation.RELATIVE_TO_PARENT , 1.1f, Animation.RELATIVE_TO_PARENT, -0.2f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);

我从我的xml anim文件开始,但我不知道如何让他知道翻译应该是相对于父级的

<translate
    android:duration="2500"
    android:fromXDelta="-0.1"
    android:fromYDelta="0"
    android:toXDelta="200"
    android:toYDelta="0" />

即我不知道如何指定fromXType属性

fromXType指定如何解释fromXValue。 Animation.ABSOLUTE,Animation.RELATIVE_TO_SELF或Animation.RELATIVE_TO_PARENT之一。

1 个答案:

答案 0 :(得分:11)

您需要使用 P 参数,例如

android:fromXDelta="-0.1%p"

read here

相关问题