Android高級(jí)UI特效仿直播點(diǎn)贊動(dòng)畫效果
本文給大家分享高級(jí)UI特效仿直播點(diǎn)贊效果—一個(gè)優(yōu)美炫酷的點(diǎn)贊動(dòng)畫,具體實(shí)現(xiàn)代碼大家參考本文。
效果圖如下:


攻克難點(diǎn):
心形圖片的路徑等走向 心形圖片的控制范圍
部分代碼如下:
通過AbstractPathAnimator定義飄心動(dòng)畫控制器
@Override
public void start(final View child, final ViewGroup parent) {
parent.addView(child, new ViewGroup.LayoutParams(mConfig.heartWidth, mConfig.heartHeight));
FloatAnimation anim = new FloatAnimation(createPath(mCounter, parent, 2), randomRotation(), parent, child);
anim.setDuration(mConfig.animDuration);
anim.setInterpolator(new LinearInterpolator());//啟動(dòng)動(dòng)畫
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
mHandler.post(new Runnable() {
@Override
public void run() {
parent.removeView(child);
}
});
mCounter.decrementAndGet();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
mCounter.incrementAndGet();
}
});
anim.setInterpolator(new LinearInterpolator());
child.startAnimation(anim);
}
/**
* 根據(jù)圖片設(shè)置bitmap
* @param color
* @return
*/
public Bitmap createHeart(int color) {
if (sHeart == null) {
sHeart = BitmapFactory.decodeResource(getResources(), mHeartResId);
}
if (sHeartBorder == null) {
sHeartBorder = BitmapFactory.decodeResource(getResources(), mHeartBorderResId);
}
Bitmap heart = sHeart;
Bitmap heartBorder = sHeartBorder;
Bitmap bm = createBitmapSafely(heartBorder.getWidth(), heartBorder.getHeight());
if (bm == null) {
return null;
}
Canvas canvas = sCanvas;
canvas.setBitmap(bm);
Paint p = sPaint;
canvas.drawBitmap(heartBorder, 0, 0, p);
p.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
float dx = (heartBorder.getWidth() - heart.getWidth()) / 2f;
float dy = (heartBorder.getHeight() - heart.getHeight()) / 2f;
canvas.drawBitmap(heart, dx, dy, p);
p.setColorFilter(null);
canvas.setBitmap(null);
return bm;
}
如何創(chuàng)建一個(gè)path
public Path createPath(AtomicInteger counter, View view, int factor) {
Random r = mRandom;
int x = r.nextInt(mConfig.xRand);
int x2 = r.nextInt(mConfig.xRand);
int y = view.getHeight() - mConfig.initY;
int y2 = counter.intValue() * 15 + mConfig.animLength * factor + r.nextInt(mConfig.animLengthRand);
factor = y2 / mConfig.bezierFactor;
//隨機(jī)xPoint
int xPointFactor = mRandom.nextInt(mConfig.xPointFactor);
x = xPointFactor + x;
x2 = xPointFactor + x2;
int y3 = y - y2;
y2 = y - y2 / 2;
Path p = new Path();
p.moveTo(mConfig.initX, y);
p.cubicTo(mConfig.initX, y - factor, x, y2 + factor, x, y2);
p.moveTo(x, y2);
p.cubicTo(x, y2 - factor, x2, y3 + factor, x2, y3);
return p;
}
Activity中代碼:



下面給大家分享一個(gè)源碼:html5+canvas仿抖音直播愛心飄動(dòng)點(diǎn)贊動(dòng)畫特效源碼
總結(jié)
以上所述是小編給大家介紹的Android高級(jí)UI特效仿直播點(diǎn)贊動(dòng)畫效果,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- android實(shí)現(xiàn)直播點(diǎn)贊飄心動(dòng)畫效果
- Android控件實(shí)現(xiàn)直播App點(diǎn)贊飄心動(dòng)畫
- Android實(shí)現(xiàn)點(diǎn)贊動(dòng)畫(27)
- Android控件FlowLikeView實(shí)現(xiàn)點(diǎn)贊動(dòng)畫
- Android實(shí)現(xiàn)簡(jiǎn)單點(diǎn)贊動(dòng)畫
- Android實(shí)現(xiàn)仿今日頭條點(diǎn)贊動(dòng)畫效果實(shí)例
- 利用Android實(shí)現(xiàn)一種點(diǎn)贊動(dòng)畫效果的全過程
相關(guān)文章
Android App開發(fā)的自動(dòng)化測(cè)試框架UI Automator使用教程
UI Automator為Android程序的UI開發(fā)提供了測(cè)試環(huán)境,這里我們就來看一下Android App開發(fā)的自動(dòng)化測(cè)試框架UI Automator使用教程,需要的朋友可以參考下2016-07-07
RecyclerView實(shí)現(xiàn)列表倒計(jì)時(shí)
這篇文章主要為大家詳細(xì)介紹了RecyclerView實(shí)現(xiàn)列表倒計(jì)時(shí),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-09-09
Android編程之Activity中onDestroy()調(diào)用分析
這篇文章主要介紹了Android編程之Activity中onDestroy()調(diào)用方法,針對(duì)onDestroy引起的內(nèi)存泄露及解決方法進(jìn)行了分析,并給出了解決方案,需要的朋友可以參考下2015-12-12
android用java和c實(shí)現(xiàn)查找sd卡掛載路徑(sd卡路徑)的方法
這篇文章主要介紹了android用java和c實(shí)現(xiàn)查找sd卡掛載路徑(sd卡路徑)的方法,需要的朋友可以參考下2014-02-02
Android三種雙屏異顯實(shí)現(xiàn)方法介紹
現(xiàn)在越來越多的Android設(shè)備有多個(gè)屏幕,雙屏異顯應(yīng)用場(chǎng)景最多的應(yīng)該就是類似于收銀平臺(tái)那種設(shè)備,在主屏上店員能夠?qū)c(diǎn)商品進(jìn)行選擇錄入,副屏則是展示給我們的賬單詳情,但是它只通過了一個(gè)軟件系統(tǒng)就實(shí)現(xiàn)了雙屏異顯這個(gè)功能,而Presentation正是這其中的關(guān)鍵2023-01-01
Android開發(fā)使用Message對(duì)象分發(fā)必備知識(shí)點(diǎn)詳解
這篇文章主要為大家介紹了Android開發(fā)使用Message對(duì)象分發(fā)必備知識(shí)點(diǎn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10
詳解Android Activity中的幾種監(jiān)聽器和實(shí)現(xiàn)方式
這篇文章主要介紹了Activity中的幾種監(jiān)聽器和實(shí)現(xiàn)方式的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-04-04
Android實(shí)現(xiàn)自動(dòng)截圖腳本
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)自動(dòng)截圖腳本,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-01-01

