Code Monkey home page Code Monkey logo

toastlibrary's Introduction

ToastLib

ToastLib is Library for Customize Toast.

Methods for implement

// ToastEnum.SHORT or ToastEnum.LONG
.duration(ToastEnum enum)

// Toast background color
.backgroundColor(int backgroundColor)

// Toast content textcolor
.textColor(int textColor)

// Toast content textsize (in SP), default is 20
.textSize(int size)

// Typeface for applying font to text
.typeface(Typeface ttf)

// true or false, for style bold to content
.isBold(boolean isBold)

// to apply fontAwesome icon, put fa-string in param
.icon(String faString)

// to add icon (drawable) in toast
.icon(int icon)

// to apply tint color on icon
.iconColor(int iconColor)

// icon size in dp, default is (24, 24)
.iconSize(int w, int h)

// corner radius for content, default is 4dp
.corner(int radius)

// margin from bottom/top (if Gravity is top then margin count from TOP and same for Bottom), default is 36
.margin(int margin)

// padding for inner content (default is 4)
.padding(int padding)

// space between icon and content, default is 8
.spacing(int spacing)

// toast UI stroke width and strokecolor
.stroke(int strokeWidth, int strokeColor)

// Gravity for placing toast (NOTE: .margin apply only for TOP and BOTTOM Gravity)
.gravity(int Gravity)

// to show toast
.show()

Usage
For Custom Toast
new ToastLib.Builder(this, "Login Success")
   .duration(ToastEnum.SHORT)
   .backgroundColor(ContextCompat.getColor(this, R.color.green))
   .textColor(ContextCompat.getColor(this, R.color.black))
   .textSize(18)
   .typeface(Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Regular.ttf"))
   .isBold(true)
   .icon(getString(R.string.fa_success))
   .icon(R.drawable.ic_check_black_24dp)
   .iconColor(ContextCompat.getColor(this, R.color.black))
   .iconSize(24, 24)
   .corner(8)
   .margin(56)
   .padding(36)
   .spacing(16)
   .stroke(2, ContextCompat.getColor(this, R.color.dark_green))
   .gravity(Gravity.BOTTOM)
   .show();
alt tag

For Success Toast
ToastLib.success(this, "Success", Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Regular.ttf"));
alt tag

For Error Toast
ToastLib.error(this, "Ooops! Try Again..", Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Regular.ttf"));
alt tag

For Loading/Progress Toast
ToastLib.progress(this, "Loading..", Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Regular.ttf"));
alt tag

toastlibrary's People

Watchers

Michael jentsch 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.