Skip to content

emreesen27/Android-Custom-Toast-Message

Repository files navigation

Android Custom Toast Message (SnToast)

Customizable Toast Message Library For Android

Add this in your root build.gradle file

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add this to your module's build.gradle file

dependencies {
  implementation 'com.github.emreesen27:Android-Custom-Toast-Message:1.0.5'
}

Usage

It very simple!

Builder

new SnToast.Builder()
        .context(MainActivity.this)
        .type(Type.SUCCESS)
        .message("Success !")
        //.cancelable(false or true) Optional Default: False
        // .iconSize(int size) Optional Default: 34dp
        // .textSize(int size) Optional Default 18sp
        // .animation(false or true) Optional Default: True
        // .duration(int ms) Optional Default: 3000ms
        // .backgroundColor(R.color.example) Default: It is filled according to the toast type. If an assignment is made, the assigned value is used
        // .icon(R.drawable.example) Default: It is filled according to the toast type. If an assignment is made, the assigned value is used
        .build();

Change Typeface

  Typeface type = ResourcesCompat.getFont(getApplicationContext(), R.font.example);
  .typeface(type) // Optional Default: sans-serif-condensed
Toast Types
  • SUCCESS
  • ERROR
  • WARNING
  • INFORMATION

Showcase

Success Toast Error Toast
Warning Toast Information Toast