Home

Awesome

SweetTips

快意灵动的提示库,自定义Toast,Snackbar,一行代码搞定多重属性设置!

为什么写这个库

详见简书: SweetTips: 快意灵动的Android提示库!

Android原生Toast及Design包中的Snackbar,实现一些常见需求比较繁琐:

Toast:

Snackbar:

截屏

  

下载

使用

SweetToast:
SweetToast toast = SweetToast.makeText(context,"backgroundResource");
SweetToast toast = SweetToast.makeText(context,"backgroundResource",Toast.LENGTH_SHORT);
SweetToast toast = SweetToast.makeText(customView);
SweetToast toast = SweetToast.makeText(context,"setWindowAnimations").setWindowAnimations(SweetToast.SweetToastWindowAnimations.AnimationTranslucent);
SweetToast toast = SweetToast.makeText(context,"setAnimations").setAnimations(R.anim.slide_in_left,R.anim.slide_out_left);
//左上
SweetToast.makeText(context,"leftTop", 1200).leftTop().show();
//右上
SweetToast.makeText(context,"rightTop", 1200).rightTop().show();
//左下
SweetToast.makeText(context,"leftBottom",1200).leftBottom().show();
//右下
SweetToast.makeText(context,"rightBottom",1200).rightBottom().show();
//上中
SweetToast.makeText(context,"topCenter",1200).topCenter().show();
//下中
SweetToast.makeText(context,"bottomCenter",1200).bottomCenter().show();
//左中
SweetToast.makeText(context,"leftCenter",1200).leftCenter().show();
//右中
SweetToast.makeText(context,"rightCenter",1200).rightCenter().show();
//正中
SweetToast.makeText(context,"center", 1200).center().show();
//指定View的上方
SweetToast.makeText(context,"layoutAbove",1200).layoutAbove(buttonTarget,statusHeight).show();
//指定View的下方
SweetToast.makeText(context,"layoutBellow",1200).layoutBellow(buttonTarget,statusHeight)show();
SweetToast.makeText(context,"setGravity").setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL,0,0).show();
SweetToast.makeText(context,"setMargin").setMargin(100f,32f).show();
ImageView iv = new ImageView(context);
iv.setImageResource(R.mipmap.ic_launcher);
SweetToast.makeText(context,"Add View").addView(iv,0).show();
SweetToast.makeText(context,"messageColor").messageColor(Color.GREEN).show();
SweetToast.makeText(context,"backgroundColor").backgroundColor(Color.GREEN).show();
SweetToast.makeText(context,"textColorAndBackground").textColorAndBackground(Color.GREEN,R.mipmap.ic_launcher).show();
SweetToast.makeText(context,"colors").colors().show(Color.GREEN,Color.BLACK);
SweetToast.makeText(context,"backgroundResource").backgroundResource(R.drawable.bg).show();
SweetToast.makeText(context,"minSize").minSize(200,160).show();
SweetToast.makeText(context,"show").show();
SweetToast.makeText(context,"showByPrevious").showByPrevious();
SweetToast.makeText(context,"showImmediate").showImmediate();
SweetSnackbar:
SnackbarUtils.Long(buttonSnackbarCustomAnim,"Snackbar自定义动画").anim(R.anim.scale_enter,R.anim.scale_exit).show();
SnackbarUtils:

注意:

TODO:

开发者:

  幻海流心
  Email: wall0920@163.com
  简书: http://www.jianshu.com/users/5702e6847f31/latest_articles
  GitHub: https://github.com/HuanHaiLiuXin