LiveGiftView - android礼物动效控件

LiveGiftView

礼物动效控件

项目链接

Preface

  • 感谢DyncKathline,本项目基于礼物动效控件LiveGiftLayout构建
  • 对于直播类app,一个好的礼物动效控件无疑会增色不少,在寻找思路的时候偶然发现个不错的轮子,故提取下来进行一些精简和拓展。

Preview

image
image

Download

Gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://www.jitpack.io' }
    }
}

and

dependencies {
    compile 'com.github.wilsonchouu:LiveGiftView:1.1.0'
}

How to use

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    ...another layout

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <me.dudu.livegiftview.GiftAnimationLayout
            android:id="@+id/layout_gift_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <me.dudu.livegiftview.GiftAnimationLayout
            android:id="@+id/layout_gift_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp" />

        <me.dudu.livegiftview.GiftAnimationLayout
            android:id="@+id/layout_gift_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp" />

    </LinearLayout>

</RelativeLayout>
GiftAnimationLayout layout1 = (GiftAnimationLayout) findViewById(R.id.layout_gift_1);
        GiftAnimationLayout layout2 = (GiftAnimationLayout) findViewById(R.id.layout_gift_2);
        GiftAnimationLayout layout3 = (GiftAnimationLayout) findViewById(R.id.layout_gift_3);
        giftController.append(layout1, new GiftViewHolder(), null, true)
                .append(layout2, new GiftViewHolder(), new DefaultAnimation1(), true)
                .append(layout3, new GiftViewHolder(), new DefaultAnimation2(), false);

MyGiftModel model = new MyGiftModel();
// set data to model...
giftController.addGift(model);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容