GithubHelp home page GithubHelp logo

smallhorse / tsnackbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jarvanzhangs/tsnackbar

0.0 2.0 0.0 4.36 MB

一个可以在顶部显示的安卓snackbar。支持显示图标,风格自定义。An android snackbar shows from the top

Java 100.00%

tsnackbar's Introduction

中文版 | 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

 

tsnackbar's People

Contributors

jarvanzhangs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.