国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android高級UI特效仿直播點贊動畫效果

2019-10-22 18:13:25
字體:
來源:轉載
供稿:網友

本文給大家分享高級UI特效仿直播點贊效果—一個優美炫酷的點贊動畫,具體實現代碼大家參考本文。

效果圖如下:

android,仿直播點贊效果,點贊特效

android,仿直播點贊效果,點贊特效

攻克難點:

心形圖片的路徑等走向 心形圖片的控制范圍

部分代碼如下:

通過AbstractPathAnimator定義飄心動畫控制器

@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());//啟動動畫 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); }/** * 根據圖片設置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; }

如何創建一個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; //隨機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中代碼:

android,仿直播點贊效果,點贊特效

android,仿直播點贊效果,點贊特效

android,仿直播點贊效果,點贊特效

 

總結

以上所述是小編給大家介紹的Android高級UI特效仿直播點贊動畫效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VEVB武林網網站的支持!


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 甘谷县| 通道| 柯坪县| 洮南市| 平湖市| 泰宁县| 永吉县| 泽州县| 尤溪县| 麻江县| 阿拉善右旗| 泊头市| 理塘县| 堆龙德庆县| 新邵县| 巴塘县| 论坛| 柳州市| 类乌齐县| 合阳县| 东城区| 华阴市| 辽源市| 荥阳市| 三原县| 万荣县| 乳山市| 小金县| 巩义市| 夏河县| 永康市| 天门市| 陇西县| 宁陕县| 宜都市| 闵行区| 永安市| 东安县| 泾川县| 贵南县| 会泽县|