2012-09-04 32 views
3

我想在xml中製作與代碼中相同的動畫。 我的代碼,我有這個如何在xml動畫文件中指定fromXType屬性

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動畫文件,但我不知道如何高大的他,翻譯應該是相對父

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

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

fromXType指定應如何解析XValue。 Animation.ABSOLUTE,Animation.RELATIVE_TO_SELF或Animation.RELATIVE_TO_PARENT之一。

回答

11

您需要使用P參數這樣

android:fromXDelta="-0.1%p" 

read here

+0

您需要使用使用-1%P時,意思是-1%。 http://developer.android.com/guide/topics/resources/animation-resource.html – enl8enmentnow

相關問題