MaterialToast
A fully and highly customizable material designed Toast for Android.
You can download the sample apk here.
Releases:
Current release: 1.0.2.
You can see all the library releases here.
Usage:
Adding the depencency
Add this to your root build.gradle file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Now add the dependency to your app build.gradle file:
implementation 'com.github.marcoscgdev:MaterialToast:1.0.2'
Creating a Toast
- Native version
MaterialToast.makeText(activity, "Hello, I'm a material toast!", Toast.LENGTH_SHORT).show();
Also with custom icon
MaterialToast.makeText(activity, "Hello, I'm a material toast!", R.mipmap.ic_launcher, Toast.LENGTH_SHORT).show();
And also with custom background color (text will be automatically colored based on background color)
MaterialToast.makeText(activity, "Hello, I'm a material toast!", R.mipmap.ic_launcher, Toast.LENGTH_SHORT).setBackgroundColor(Color.RED).show();
NEW! With custom duration (in millis):
MaterialToast.makeText(activity, "Hello, I'm a material toast!", R.mipmap.ic_launcher, 4000).setBackgroundColor(Color.RED).show();
- Complete version
new MaterialToast(activity)
.setMessage("Hello, I'm a material toast!")
.setIcon(R.mipmap.ic_launcher)
.setDuration(Toast.LENGTH_SHORT)
.setBackgroundColor(Color.RED)
.show();