GiftSurfaceView 直播间送礼物动画

作者: androidproject 发布时间: 2019-09-05 浏览: 2466 次 编辑

GiftSurfaceView 最初出自于2014年开发HalloStar项目时所写,主要用于HalloStar项目直播间的送礼物动画。现在想来,那夕阳下的奔跑,是我逝去的青春。因高仿全民TV项目时想起,所以抽空整理了下,以此记录。

Gif展示

gif

引入

Maven:

<dependency>
  <groupId>com.king.view</groupId>
  <artifactId>giftsurfaceview</artifactId>
  <version>1.1.0</version>
  <type>pom</type>
</dependency>

Gradle:

compile 'com.king.view:giftsurfaceview:1.1.0'

Lvy:

<dependency org='com.king.view' name='giftsurfaceview' rev='1.1.0'>
  <artifact name='$AID' ext='pom'></artifact>
</dependency>
如果Gradle出现compile失败的情况,可以在Project的build.gradle里面添加如下:(也可以使用上面的GitPack来complie)
allprojects {    
 repositories {  
        maven { 
        url 'https://dl.bintray.com/jenly/maven'
         }    
   
   }
}

示例

 public void updateGiftSurfaceView(int type){

        frame.removeAllViews();

        GiftSurfaceView giftSurfaceView = new GiftSurfaceView(context);
        if(type == RANDOM){
            giftSurfaceView.setImageResource(R.drawable.rose);
        }else{
            giftSurfaceView.setImageBitmap(bitmap,.5f);
        }

        giftSurfaceView.setPointScale(1,width/10,(int)(height/3.8f));
        giftSurfaceView.setRunTime(10000);

        try {

            switch (type){
                case RANDOM:
                    giftSurfaceView.setRandomPoint(9);
                    break;
                case V:
                    giftSurfaceView.setListPoint(PointUtils.getListPointByResourceJson(context,ASSET_V),true);
                    break;
                case HEART:
                    giftSurfaceView.setListPoint(PointUtils.getListPointByResourceJson(context,ASSET_HEART),true);
                    break;
                case LOVE:
                    giftSurfaceView.setListPoint(PointUtils.getListPointByResourceJson(context,ASSET_LOVE));
                    break;
                case SMILE:
                    giftSurfaceView.setListPoint(PointUtils.getListPointByResourceJson(context,ASSET_SMILE));
                    break;
                case X:
                    giftSurfaceView.setListPoint(PointUtils.getListPointByResourceJson(context,ASSET_X));
                    break;
                case V520:
                    giftSurfaceView.setListPoint(PointUtils.getListPointByResourceJson(context,ASSET_V520));
                    break;
                case V1314:
                    giftSurfaceView.setRunTime(GiftSurfaceView.LONG_TIME);
                    giftSurfaceView.setListPoint(PointUtils.getListPointByResourceJson(context,ASSET_V1314));
                    break;

            }
            frame.addView(giftSurfaceView);
        } catch (IOException e) {
            e.printStackTrace();
        }


    }

以上为部分代码使用示例,更多详情请下载查看。

赞赏

如果您喜欢GiftSurfaceView,或感觉GiftSurfaceView帮助到了您,可以点右上角“Star”支持一下,您的支持就是我的动力,谢谢 ????

您也可以扫描下面的二维码,请作者喝杯咖啡 ☕️

   


关于我

Name: Jenly

Email: jenly1314#gmail.com / jenly1314#vip.qq.com

CSDN: jenly121

Github: jenly1314

加入QQ群: 20867961

 

项目地址:https://github.com/jenly1314/GiftSurfaceView