欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

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

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

目前成都創(chuàng)新互聯(lián)已為上千的企業(yè)提供了網(wǎng)站建設、域名、網(wǎng)絡空間、網(wǎng)站托管、服務器租用、企業(yè)網(wǎng)站設計、碧江網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

效果圖如下:

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

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

攻克難點:

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

部分代碼如下:

通過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);
 }

/**
 * 根據(jù)圖片設置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)建一個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高級UI特效仿直播點贊動畫效果

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

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

下面給大家分享一個源碼:html5+canvas仿抖音直播愛心飄動點贊動畫特效源碼

總結

以上所述是小編給大家介紹的Android高級UI特效仿直播點贊動畫效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對創(chuàng)新互聯(lián)網(wǎng)站的支持!

標題名稱:Android高級UI特效仿直播點贊動畫效果
URL分享:http://www.chinadenli.net/article26/igpecg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供服務器托管微信公眾號網(wǎng)站改版云服務器靜態(tài)網(wǎng)站建站公司

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

外貿網(wǎng)站建設