一个可以在顶部显示的安卓snackbar。支持显示图标,风格自定义。An android snackbar shows from the top
Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gradle/3.3
.idea
app
gradle/wrapper
screenshot
tsnackbar
.gitignore
README.md
README_CN.md
build.gradle
demo.gif
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

中文版 | English
TSnackbar

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

Effect

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