简体   繁体   中英

How to specify the fromXType attribute in xml anim file

I want to make the same animation in xml as in code. I code I have this

    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);

I start with this in my xml anim file but I do not know how to tall him that the translation should be relative to parent

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

Namely I do not know how to specify the fromXType attribute

fromXType Specifies how fromXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.

you need to use the P parameter like this

android:fromXDelta="-0.1%p"

read here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM