0

在Android中,我正在尋找儘可能簡單的「內置」方式,創建一個可繪製或自定義的動畫4個同心圓的緩慢擴展半徑的視圖。安卓動畫的同心擴張漸隱圈

expanding fading concentric circles

在哪裏將是最好的地方開始?
是否有可能在純XML中做到這一點?
如果不是,可以使用單層drawable來完成,還是應該使用多層drawable?

謝謝!

+0

嘗試通過android阿森納。那將是您尋找這種事情的最佳首選。 – eddiecubed

+0

嘗試搜索Animated Drawables。 – Enzokie

+0

@swooby我也試圖做這樣的事情,但只使用單層drawable,雖然我不知道你是如何動畫每個項目列表在你的可繪製的XML我問了一個問題,但沒有回答它呢。請幫助 – SameerKhan1406

回答

2

最好的地方是this repository。這是一個易於配置的紋波背景動畫,用於Android。插入它,你準備好了。以下是具體步驟:

要在安裝後設置它,添加RippleBackground到您的佈局像這樣,

<com.skyfishjy.library.RippleBackground 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/content" 
    app:rb_color="#0099CC" 
    app:rb_radius="32dp" 
    app:rb_rippleAmount="4" 
    app:rb_duration="3000" 
    app:rb_scale="6"> 
    <ImageView 
     android:layout_width="64dp" 
     android:layout_height="64dp" 
     android:layout_centerInParent="true" 
     android:id="@+id/centerImage" 
     android:src="@drawable/demoImage"/> 
</com.skyfishjy.library.RippleBackground> 

那麼你可以通過重寫的onClick方法是這樣開始的動畫,

final RippleBackground rippleBackground=(RippleBackground)findViewById(R.id.content); 
ImageView imageView=(ImageView)findViewById(R.id.centerImage); 
imageView.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View view) { 
     rippleBackground.startRippleAnimation(); 
    } 
}); 

調用方法rippleBackground.stopRippleAnimation()停止動畫。

希望它有幫助。