2016-05-31 48 views
4

不工作我有一個動畫列表XML繪製anim_progress.xml動畫列表帶有刻度標記的棉花糖

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item android:duration="100"> 
     <scale android:drawable="@drawable/frame_1" android:scaleGravity="center"/> 
    </item> 

    <item android:duration="100"> 
     <scale android:drawable="@drawable/frame_2" android:scaleGravity="center"/> 
    </item> 

    <item android:duration="100"> 
     <scale android:drawable="@drawable/frame_3" android:scaleGravity="center"/> 
    </item> 

    . 
    . 
    . 

</animation-list> 

我用scale標籤,因爲圖像frame_x.png比容器查看大圖。其原因是適合大多數屏幕尺寸的能力。

我用這個幀動畫作爲我的自定義進度的indeterminateDrawable

<ProgressBar 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:indeterminateOnly="true" 
    android:indeterminate="true" 
    android:foregroundGravity="center" 
    android:indeterminateDrawable="@drawable/anim_progress" 
    /> 

它工作在棉花糖之前的Android版本確定。我檢查過仿真器和設備。 但在棉花糖,它什麼也沒有顯示。空白的空白空間。以及Android Studio中的預覽窗格。

如果我從animation-list中刪除scale標記,它在棉花糖中運行良好,並且可以按照正確的方式進行縮放,但似乎會在其他Android版本中裁剪。

我知道我可以在drawable-v23文件夾中創建單獨的文件,在此之前我想問問是否有人可以通過xml共享其他縮放進度欄框架動畫的技巧。

回答

0

我遇到了同樣的問題。我不知道爲什麼它不在Marhmallow中工作,但是解決方法是使用rotate作爲intermediatDrawable而不是動畫列表。

事情是這樣的:

<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
android:duration="250" 
android:fromDegrees="359" 
android:toDegrees="0" 
android:pivotX="50%" 
android:pivotY="50%" 
android:repeatCount="infinite" 
android:interpolator="@android:anim/linear_interpolator" 
android:drawable="@drawable/icn_refresh"> 
</rotate> 
+0

是的,旋轉會的工作,但它不是動畫列表周圍的工作:)我我的情況,我有一個非旋轉物體的幀動畫幀,所以旋轉將無濟於事。 –