项目作者: Poizi

项目描述 :
Android custom Toast
高级语言: Java
项目地址: git://github.com/Poizi/PoiziToast.git
创建时间: 2017-02-21T14:15:26Z
项目社区:https://github.com/Poizi/PoiziToast

开源协议:MIT License

下载


Poizi Toast

The PoiziToast library enhances and builds upon the Android Toast class. This library offers many customization options over the standard Android Toast class.

Screenshots

Normal
Error
Info
Warning
Success
Custom

Dependency

Usage

  1. Add this in your root build.gradle file:
  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url "https://jitpack.io" }
  5. }
  6. }
  1. Add this to your module’s build.gradle file:
  1. dependencies {
  2. ...
  3. compile 'com.github.farshidabz:poizitoast:v1.0.1'
  4. }
  1. How to use:

Each method always returns a PoiziToast object, so you can customize the Toast much more. DON’T FORGET THE show() METHOD!

  • Normal Toast:

    1. PoiziToast.with(this)
    2. .normal("Normal Toast", Toast.LENGTH_SHORT)
    3. .show();
  • Warning Toast:

    1. PoiziToast.with(this)
    2. .warning("warning Toast", Toast.LENGTH_SHORT)
    3. .show();
  • Error Toast:

    1. PoiziToast.with(this)
    2. .error("error Toast", Toast.LENGTH_SHORT)
    3. .show();
  • Info Toast:

    1. PoiziToast.with(this)
    2. .info("info Toast", Toast.LENGTH_SHORT)
    3. .show();
  • Success Toast:

    1. PoiziToast.with(this)
    2. .success("success", Toast.LENGTH_SHORT)
    3. .show();
  • Custom Toast:

    1. PoiziToast.with(this)
    2. .setBackgroundColor(getResources().getColor(R.color.colorAccent))
    3. .setIcon(R.drawable.battery_charging_full)
    4. .setGravity(Gravity.BOTTOM)
    5. .setTextColor(R.color.textColor)
    6. .setTextTypeFace(Typeface.createFromAsset(getAssets(), "fonts/font.ttf"))
    7. .setTextSize(14)
    8. .makeToast("custom text", Toast.LENGTH_SHORT)
    9. .show();

Attributes

attribute name attribute description
icon The icon of Poizi Toast.
gravity The gravity of Poizi Toast.
TextSize The message’s text size.
TextColor The message’s text color.
TextTypeFace The message’s text type face.
BackgroundColor The background color of Poizi Toast.