10 Star 34 Fork 7

追逐梦想meng / SnackbarUtils

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README

SnackbarUtils

版本规划:

  • v1.0.0 采用建造者模式实现Snackbar的使用,添加多彩的示例
  • v1.1.0 增加可以自定义显示的view,优化细节以及修复重复绘制,提升性能
  • v1.1.1 增加snackbar显示和消失的callback
  • v1.2.0 增加snackbar与各种控件的联动等【当snackbar弹出的时候,指定控件上移】
  • v..... 欢迎留言,欢迎制定版本规划,一起打造漂亮的snackbar

效果图 欢迎star 欢迎frok

使用方式

Step 1. Add the JitPack repository to your build file

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

Step 2. Add the dependency

dependencies {
    //依赖库
    implementation 'com.android.support:design:27.1.0'
    compile 'com.github.mengpeng920223:SnackbarUtils:v1.1.1'
}

使用示例 V1.1.1

  • 新增使用自定义view
View inflate = LayoutInflater.from(this).inflate(R.layout.item_view, null);
SnackbarUtils
    //第一个参数:activity , 第二个:自定义的view , 第三个:view的高度,单位是dp
    .create(MainActivity.this, inflate, 100)
    .setDuration(time)  //设置显示时长
    .addCallBack(new BaseTransientBottomBar.BaseCallback<Snackbar>() {
        @Override
        public void onDismissed(Snackbar transientBottomBar, int event) {
            ToastUtils.onSuccessShowToast("消失");
        }
    
        @Override
        public void onShown(Snackbar transientBottomBar) {
            ToastUtils.onSuccessShowToast("显示");
        }
    })
    .build();  //创建并show  必须调用
    
..... = inflate.findViewById(...);   
.....
    
  • 优化体验,修复重复绘制

使用示例 V1.0.0

SnackbarUtils
    .create(MainActivity.this)           //  .create(Activity activity) 必须
    .setIcon(R.mipmap.toast_error)       //  左边的icon
    .setContent("失败")                   //  提示文字
    .setSnackbarBackgroundColor(R.color.toastErrorColor)  // 背景颜色
    .setActionBtn1("按钮1", new View.OnClickListener() {  // 按钮1
        @Override
        public void onClick(View v) {
            Log.d("MainActivity", "按钮1");
        }
    })
    .setActionBtn2("按钮2", new View.OnClickListener() {  // 按钮2
        @Override
        public void onClick(View v) {
            Log.d("MainActivity", "按钮2");
        }
    })
    .addCallBack(new BaseTransientBottomBar.BaseCallback<Snackbar>() {
        @Override
        public void onDismissed(Snackbar transientBottomBar, int event) {
            ToastUtils.onSuccessShowToast("消失");
        }
    
        @Override
        public void onShown(Snackbar transientBottomBar) {
            ToastUtils.onSuccessShowToast("显示");
        }
    })
    .setDuration(Snackbar.LENGTH_INDEFINITE)  //设置显示时长
    .build();  //创建并show  必须调用

推荐 ToastUtils

是时候改变一下你的toast了,让你的toast变个样子吧。最简单炫酷的toast,一行代码实现多种提示,关键是简单,好看,你值得拥有。

Empty file

About

V1.1.1版本更新支持自定义view,snackbar显示和消失的callback,方便定制自己想要的效果。你还在用toast?那你就out啦,快来尝试这个炫酷的Snackbar吧。最简单炫酷的Snackbar简单,好看,你值得拥有。快来看看效果吧。 expand collapse
Android
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Android
1
https://gitee.com/mengpeng920223/SnackbarUtils.git
git@gitee.com:mengpeng920223/SnackbarUtils.git
mengpeng920223
SnackbarUtils
SnackbarUtils
master

Search