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

3

我希望能够用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 指定从X值应该如何解释。可以为以下之一:Animation.ABSOLUTE(绝对值),Animation.RELATIVE_TO_SELF(相对于自身),或者 Animation.RELATIVE_TO_PARENT(相对于父元素)。

1个回答

11

在使用%p时,您需要使用-1来表示-1%。http://developer.android.com/guide/topics/resources/animation-resource.html - enl8enmentnow

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接