android天女散花效果_Android有趣的爆炸散落动画view:开源ExplosionField
Android有趣的爆炸散落動(dòng)畫view:開源ExplosionField
github上有一個(gè)比較有趣的view動(dòng)畫開源項(xiàng)目ExplosionField,當(dāng)點(diǎn)擊該view時(shí)候,產(chǎn)生如圖所示效果:
猶如天女散花一樣,爆炸散列,比較有趣。
Android ExplosionField在github上的項(xiàng)目主頁(yè)是:https://github.com/tyrantgit/ExplosionField
Android ExplosionField使用簡(jiǎn)單,幾乎可以針對(duì)任意的view制造出上圖所示效果。
ExplosionField使用之前先需要到其github上的主頁(yè)將其拖下來(lái),導(dǎo)入作為lib使用。
現(xiàn)給出一個(gè)簡(jiǎn)單的代碼例子說(shuō)明,測(cè)試的主activity MainActivity.java:
package zhangphil.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import tyrantgit.explosionfield.ExplosionField;
public class MainActivity extends Activity {
private ExplosionField mExplosionField;
private ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 先初始化載入ExplosionField
mExplosionField = ExplosionField.attach2Window(this);
image = (ImageView) findViewById(R.id.image);
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 開始執(zhí)行動(dòng)畫...
mExplosionField.explode(v);
// ExplosionField.explode后,父布局中雖看不到ImageView,但I(xiàn)mageView所占據(jù)的位置還會(huì)響應(yīng)事件.
// 如果想屏蔽此ImageView出現(xiàn),則:
image.setVisibility(View.GONE);
}
});
}
}
MainActivity.java需要的布局文件activiy_main.xml,很簡(jiǎn)單的一個(gè)ImageView:
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dip" >
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#c62828"
android:src="@drawable/ic_launcher" />
總結(jié)
以上是生活随笔為你收集整理的android天女散花效果_Android有趣的爆炸散落动画view:开源ExplosionField的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 火币网的macd怎么算的_黄金投资中MA
- 下一篇: lua 字符串分割_Lua 分隔字符串,