2013-10-23 61 views
0

我有一個ImageView有一張圖片。當用戶做某事時,我希望圖片更改爲其他資源。Android ImageView開關資源與動畫

我發現這個解決方案: Creating animation on ImageView while changing image resource

但它首先淡出當前圖像,然後在新的一個變淡。我想要的是,同時第一個資源淡出,淡入的新圖片。

我在考慮使用2個ImageView,一個淡入淡出,另一個淡出。但我想知道是否可以使用單個ImageView來完成。

(我不想一定淡入淡出動畫...合併/混合無論是也沒關係)

謝謝!

回答

0

最後使用ViewFlipper在兩個「圖像」之間切換。

<ViewFlipper 
    android:id="@+id/view_flipper" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ImageView 
     android:id="@+id/background_level" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerCrop" 
     android:src="@drawable/background_level_1" /> 

    <ImageView 
     android:id="@+id/background_level_flip1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerCrop" 
     android:src="@drawable/background_level_2" /> 
</ViewFlipper>