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.4'
}
Usage
It very simple!
Toast Types
- SUCCESS
- ERROR
- WARNING
- INFORMATION
Standard
new SnToast.Standard()
.context(YourActivity.this)
.type(Type.SUCCESS)
.message("Success !")
// .iconSize(int size) Optional Default: 34dp
// .textSize(int size) Optional Default 18sp
// .animation(false or true) Optional Default: True
// .cancelable(false or true) Optional Default: False
// .duration(int ms) Optional Default: 3000ms
.build();
Custom
new SnToast.Custom()
.context(YourActivity.this)
.backgroundColor(R.color.your_bg_color)
.textColor(R.color.your_text_color)
.icon(R.drawable.your_icon)
.message("Custom !!!")
// .iconSize(int size) Optional Default: 34dp
// .textSize(int size) Optional Default 18sp
// .animation(false or true) Optional Default: True
// .cancelable(false or true) Optional Default: False
// .duration(int ms) Optional Default: 3000ms
.build();
Change Typeface (Standard or Custom)
Typeface type = ResourcesCompat.getFont(getApplicationContext(), R.font.example);
.typeface(type) // Optional Default: sans-serif-condensed
Showcase
Success Toast | Error Toast |
---|---|
Warning Toast | Information Toast |
---|---|