惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
H
Help Net Security
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
A
About on SuperTechFans
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
I
InfoQ
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
U
Unit 42
The Cloudflare Blog
Y
Y Combinator Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Introducing ToastLib v3.0.1 - A Modern Android Toast Libr...
Akshay · 2026-06-02 · via DEV Community

Akshay

Android Toast messages are one of the simplest ways to show quick feedback to users.

But the default Android Toast often feels too basic when you are building a modern app.

That is why I created ToastLib.

ToastLib is a lightweight Android library that helps you show beautiful custom toast messages with icons, colors, different toast types, custom gravity, and a clean API.

With ToastLib v3.0.1, the library is now more flexible, more customizable, and easier to use in real Android projects.


What is ToastLib?

ToastLib is a custom Android toast library built for developers who want better looking feedback messages without writing the same custom toast layout again and again.

It supports ready-to-use toast types such as:

  • Success
  • Error
  • Info
  • Warning
  • Default

Example:

ToastLib.success(this, "Saved successfully");
ToastLib.error(this, "Something went wrong");
ToastLib.info(this, "Welcome back!");
ToastLib.warning(this, "Please check your input");
ToastLib.show(this, "Default toast message");

Simple, clean, and easy to use.


Why ToastLib?

The default Android Toast works, but it is limited.

Toast.makeText(this, "Saved successfully", Toast.LENGTH_SHORT).show();

This is fine for simple apps, but modern apps often need better UI feedback.

ToastLib solves this by providing:

  • Custom toast layouts
  • Built-in icons
  • Colored backgrounds
  • Multiple toast types
  • Android 11+ compatible custom toast UI
  • Easy static methods
  • Advanced builder API
  • Custom gravity and duration support

What is New in v3.0.1?

ToastLib v3.0.1 focuses on stability, better toast handling, and improved developer experience.

New Builder API

The new Builder API gives you more control over toast design and behavior.

ToastLib.builder(this)
        .setMessage("Profile updated successfully")
        .setType(ToastLib.ToastType.SUCCESS)
        .setGravity(Gravity.TOP)
        .setDuration(Toast.LENGTH_LONG)
        .show();

This is useful when you want to customize toast behavior without creating multiple overloaded methods.


New Warning Toast

ToastLib now includes a warning toast type.

ToastLib.warning(this, "Please check your input");

This is useful for form validation, incomplete data, permission warnings, and caution messages.


Basic Usage

Success Toast

ToastLib.success(this, "Saved successfully");

Error Toast

ToastLib.error(this, "Something went wrong");

Info Toast

ToastLib.info(this, "Welcome back!");

Warning Toast

ToastLib.warning(this, "Please check your input");

Default Toast

ToastLib.show(this, "Default toast message");


Long Duration Toasts

ToastLib also includes helper methods for longer messages.

ToastLib.successLong(this, "Your changes have been saved successfully");
ToastLib.errorLong(this, "Unable to complete the request");


Custom Position Toast

You can show toast messages at different positions.

ToastLib.show(
        this,
        "Top message",
        ToastLib.ToastType.INFO,
        Gravity.TOP
);

Or use helper methods:

ToastLib.top(this, "Message from top");
ToastLib.center(this, "Centered toast message");


Custom Builder Toast Example

Here is an example of a customized toast using the Builder API:

ToastLib.builder(this)
        .setMessage("Custom toast message")
        .setType(ToastLib.ToastType.SUCCESS)
        .setGravity(Gravity.BOTTOM)
        .setYOffset(180)
        .setDuration(Toast.LENGTH_LONG)
        .setHideIcon(false)
        .show();

The Builder API makes ToastLib easier to extend and more useful for production apps.


Customization Support

ToastLib v3.0.1 supports:

  • Custom background color
  • Custom text color
  • Custom icon
  • Hide icon option
  • Icon tint support
  • Custom corner radius
  • Custom padding
  • Custom gravity
  • Custom X/Y offset
  • Short and long duration

This makes it easy to match the toast style with your app branding.


Installation

ToastLib is available through JitPack.

Step 1: Add JitPack Repository

Add JitPack in your settings.gradle or settings.gradle.kts.

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven("https://jitpack.io")
    }
}


Step 2: Add ToastLib Dependency

If your GitHub release tag is v3.0.1, use:

dependencies {
    implementation 'com.github.TutorialsAndroid:Toast-Library:v3.0.1'
}

For Kotlin DSL:

dependencies {
    implementation("com.github.TutorialsAndroid:Toast-Library:v3.0.1")
}


Version Catalog Setup

If you are using Gradle Version Catalog, add this in libs.versions.toml:

[versions]
toastlib = "v3.0.1"

[libraries]
toastlib = { module = "com.github.TutorialsAndroid:Toast-Library", version.ref = "toastlib" }

Then use it inside your app module:

dependencies {
    implementation(libs.toastlib)
}


Backward Compatibility

Old code still works.

ToastLib.success(this, "Saved successfully");
ToastLib.error(this, "Something went wrong");
ToastLib.info(this, "Welcome back!");
ToastLib.show(this, "Default toast");

So existing users can upgrade without rewriting their current implementation.


When Should You Use ToastLib?

ToastLib is useful when you want:

  • Better looking toast messages
  • Clean UI feedback
  • Success, error, info, warning, and default states
  • A simple API for beginners
  • A builder API for advanced customization
  • Android 11+ compatible custom toast UI
  • Lightweight integration without complex setup

GitHub Repository

You can check out the project here:

https://github.com/TutorialsAndroid/Toast-Library

If you find this project useful, please consider giving it a star on GitHub.

It helps the project grow and motivates me to keep improving it.


Final Thoughts

ToastLib started as a simple Android toast helper library.

With v3.0.1, it is now more powerful, customizable, and production-ready.

If you are building an Android app and want modern toast messages with icons, colors, and clean API usage, ToastLib can save time and improve your app experience.

Thanks for reading.

Happy coding!