TSnackbar

项目地址:AbbyJM/TSnackbar
简介:一个从顶部滑出的 snackbar
更多:作者   提 Bug   
标签:
snackbar-topsnackbar-顶部snackbar-

中文版 | English

A snackbar can be shown from top or bottom.

Introduction

It is customizable and easy to use.You can change the style of the snackbar or apply the predefined styles,which are ERROR,LOADING,COMPLETE,WARNING

ScreenShot

STYLE_ERROR

STYLE_COMPLETE

CUSTOMIZE YOUR ICON

STYLE_LOADING

Gradle

    dependencies{
        compile 'com.abby.app:tsnackbar:1.0.7' 
     }

Update

v1.0.6:
  1.new method setHeight(int height) to set the height of the snackbar
v1.0.7:
  1.new method setMessageGravity(int gravity) to set the gravity of the message text
  2.new method setActionTextSize(float size) to set the size of the action button
  3.upgrade API version to 26,so do not forget to upgrade your API version 

Usage

       @Override
       public void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);
           TSnackbar.make(getWindow().getDecorView(),"LOADING PLEASE WAIT...",TSnackbar.LENGTH_LONG)
                        .setPreDefinedStyle(TSnackbar.STYLE_LOADING)
                        .show();
          TSnackbar.make(getWindow().getDecorView(),"ERROR OCCURED!",TSnackbar.LENGTH_LONG)
                        .setPreDefinedStyle(TSnackbar.STYLE_ERROR)
                        .show();
          TSnackbar.make(getWindow().getDecorView(),"COMPLETE",TSnackbar.LENGTH_LONG)
                        .setPreDefinedStyle(TSnackbar.STYLE_COMPLETE)
                        .show();
          TSnackbar.make(getWindow().getDecorView(),"LOADING...",TSnackbar.LENGTH_LONG)
                        .setIconRes(R.drawable.ic_wifi_black_24dp)
                        .setBackgroundColor(Color.GREEN)
                        .show();
    }

Features

name description
setShowsDirection set the direction the snackbar shows,which can be SHOW_FROM_TOP_TO_BOTTOM or SHOW or SHOW_FROM_BOTTOM_TO_TOP
setBackgroundColor set the color of the background
setAlpha set the alpha of the background,should be 0 to 255
setMessageTextColor set the color of the message
setIconRes set the Icon resource
setIconRes set Icon res with sizes in px
setPreDefinedStyle apply the predefined style,which are STYLE_ERROE,STYLE_COMPLETE,STYLE_LOADING,STYLE_WARNING
setFadeOrTranslateStyle set the style the snackbar animate out,which can be STYLE_FADE_OUT,STYLE_FADE_IN,STYLE FADE_IN_FADE_OUT or STYLE_TRANSLATE
isBelowStatusBar indicate if the snackbar is below the statusbar
setHeight set the height of snackbar in dp,to get a better effect,recommend use a value greater than 120 due to the padding,the default height is wrap_content
setActionTextSize(float size) set the font size of the action button
setMessageGravity(int gravity) set the gravity of the message text,must be one of Gravity.START,Gravity.CENTER or Gravity.END.The default gravity is Gravity.START

License

Copyright 2017 AbbyJM

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
随手点击下面广告,支持我维护本站吧