2013-09-30 27 views
2

是否有可能有一個這樣的動畫:我可以將android:動畫列表項的持續時間移動到attrs.xml嗎?

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false" > 

    <item 
     android:drawable="@drawable/pr_l_b01" 
     android:duration="@dont-know-what/animation_frame_duration"/> 
    <item 
     android:drawable="@drawable/pr_l_b02" 
     android:duration="@dont-know-what/animation_frame_duration"/> 
    <item 
     android:drawable="@drawable/pr_l_b03" 
     android:duration="@dont-know-what/animation_frame_duration"/> 

</animation-list> 

attrs.xml

<dont-know-what name="animation_frame_duration"/></dont-know-what> 

回答

5

看看android開發人員的duration屬性。

這也可能是對資源的引用(形式爲「@ [package:] type:name」)或主題屬性(形式爲「?[package:] [type:] name」)包含這種類型的值。

插入values.xml你的時間價值是這樣的:

<resources> 
    <integer name="duration">700</integer> 
</resources> 

而且使用這樣的:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false" > 

    <item 
     android:drawable="@drawable/pr_l_b01" 
     android:duration="@integer/duration"/> 

</animation-list> 
+0

太可惜了。這麼簡單......;)讓我試試你的例子... –

+0

具體例子的答案總是更好!做得好!希望它有幫助;) –

+0

;) – Dyna