FlipShare分享控件

项目地址:https://github.com/JeasonWong/FlipShare

效果图:

Markdown

这段时间做了蛮多动画效果,那就趁热打铁,停不下来~

我发现开源的分享控件很稀少,大部分要么就是直接一个Dialog,要么就是简单的PopupWindow,于是决定撸一发。效果略浮夸,但是用来学习Camera和Matrix也是勉强可以的。为了重拾Matrix,特意看了下线性代数的60页PPT。

使用方式很简单,通过Builder模式构造。

1
2
3
4
5
6
7
8
9
10
FlipShareView share = new FlipShareView.Builder(this, mBtnLeftTop)
.addItem(new ShareItem("Facebook", Color.WHITE, 0xff43549C, BitmapFactory.decodeResource(getResources(), R.mipmap.ic_facebook)))
.addItem(new ShareItem("Twitter", Color.WHITE, 0xff4999F0, BitmapFactory.decodeResource(getResources(), R.mipmap.ic_twitter)))
.addItem(new ShareItem("Google+", Color.WHITE, 0xffD9392D, BitmapFactory.decodeResource(getResources(), R.mipmap.ic_google)))
.addItem(new ShareItem("http://www.wangyuwei.me", Color.WHITE, 0xff57708A))
.setBackgroundColor(0x60000000)
.setItemDuration(500)
.setSeparateLineColor(0x30000000)
.setAnimType(FlipShareView.TYPE_SLIDE)
.create();

目前支持三种动画方式

1
2
3
@IntDef(flag = true, value = {TYPE_VERTICLE, TYPE_HORIZONTAL, TYPE_SLIDE})
public @interface AnimType {
}

可以设置每个Item的动画时长;

1
.setItemDuration(500)

可以设置背景色(部分需求是透明色背景)

1
.setBackgroundColor(0x60000000)

可以设置每个item的分割线色

1
.setSeparateLineColor(0x30000000)

添加item也很简单,来看看item的实体类。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class ShareItem {
public String title;
public int titleColor = Color.BLACK;
public int bgColor = Color.WHITE;
public Bitmap icon;
public ShareItem(String title) {
this.title = title;
}
public ShareItem(String title, Bitmap icon) {
this.title = title;
this.icon = icon;
}
public ShareItem(String title, int bgColor) {
this.title = title;
this.bgColor = bgColor;
}
public ShareItem(String title, int titleColor, int bgColor) {
this.title = title;
this.titleColor = titleColor;
this.bgColor = bgColor;
}
public ShareItem(String title, int bgColor, Bitmap icon) {
this.title = title;
this.bgColor = bgColor;
this.icon = icon;
}
public ShareItem(String title, int titleColor, int bgColor, Bitmap icon) {
this.title = title;
this.titleColor = titleColor;
this.bgColor = bgColor;
this.icon = icon;
}
}

纯文案、文案+图片都可以。

目前暂时支持这些内容,欢迎各位提交pr,或者多多开源一些关于分享的控件~

如果有更好的思路,欢迎交流,开源本身就是大家互相喷喷,互相进步嘛,
对各种动画感兴趣的朋友欢迎加群479729938进行交流,
期待各种好看,好玩,实用的动画~

Markdown