Toasty Library Converted By Gabriel
this example notification with custome.
this support for sketchware.
Each method always returns a Toast object, so you can customize the Toast much more.
**DON'T FORGET THE show() METHOD!**
To display an error Toast:
Toasty.error(yourContext, "This is an error toast.", Toast.LENGTH_SHORT, true).show();
To display a success Toast:
Toasty.success(yourContext, "Success!", Toast.LENGTH_SHORT, true).show();
To display an info Toast:
Toasty.info(yourContext, "Here is some info for you.", Toast.LENGTH_SHORT, true).show();
To display a warning Toast:
Toasty.warning(yourContext, "Beware of the dog.", Toast.LENGTH_SHORT, true).show();
To display the usual Toast:
Toasty.normal(yourContext, "Normal toast w/o icon").show();
To display the usual Toast with icon:
Toasty.normal(yourContext, "Normal toast w/ icon", yourIconDrawable).show();
You can also create your custom Toasts with the `custom()` method:
Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, tintColor, duration, withIcon,
shouldTint).show();
Installed Sketchware:- Upload Image
- Add toast_layout.xml
- Add toast_icon (ImageView) on linear make sure 24x24 and set default.png as default image
- Add toast_text (TextView) on linear
How To Use For sketchware?
# Error Type:
Toasty.error(MainActivity.this, "This is an error toast.", Toast.LENGTH_SHORT, true).show();
# Success Type:
Toasty.success(MainActivity.this, "Success!", Toast.LENGTH_SHORT, true).show();
# Info Type:
Toasty.info(MainActivity.this, "Here is some info for you.", Toast.LENGTH_SHORT, true).show();
# Warning Type:
Toasty.warning(MainActivity.this, "Beware of the dog.", Toast.LENGTH_SHORT, true).show();
# Normal Withouth Icon:
Toasty.normal(MainActivity.this, "Normal toast w/o icon").show();
# Normal With Icon:
android.graphics.drawable.Drawable icon = getResources().getDrawable(R.drawable.ic_pets_white_48dp);
Toasty.normal(MainActivity.this, "Normal toast w/ icon", icon).show();
# Format Type:
Toasty.info(MainActivity.this, getFormattedMessage()).show();
# This Format:
private CharSequence getFormattedMessage() {
final String prefix = "Formatted ";
final String highlight = "bold italic";
final String suffix = " text";
android.text.SpannableStringBuilder ssb = new android.text.SpannableStringBuilder(prefix).append(highlight).append(suffix);
int prefixLen = prefix.length();
ssb.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD_ITALIC),
prefixLen, prefixLen + highlight.length(), android.text.Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return ssb;
}
# Custome Config
Toasty.Config.getInstance()
.setTextColor(Color.GREEN)
.setToastTypeface(Typeface.createFromAsset(getAssets(), "fonts/terminal.ttf"))
.apply();
Toasty.custom(MainActivity.this, "Converted By Gabriel", getResources().getDrawable(R.drawable.laptop512), Color.BLACK, Toast.LENGTH_SHORT, true, true).show();
Toasty.Config.reset();
Library Toasty Download Here
Demo app make by sketchware Download here