Convert Figma logo to code with AI

Muddz logoStyleableToast

[Moved to MavenCentral] An Android library that takes the standard toast to the next level with many styling options. Works on all Android versions.

2,078
271
2,078
2

Top Related Projects

5,515

An Android Alerting Library

6,569

The usual Toast, but with steroids 💪

:bread: Make your native android Toasts Tasty

A library that extends the Android toast framework.

🌈 A Beautiful Motion Toast Library for Kotlin Android

Quick Overview

StyleableToast is an Android library that enhances the standard Android Toast, offering customizable and stylish toast notifications. It provides a wide range of styling options, including custom backgrounds, icons, fonts, and animations, allowing developers to create visually appealing and branded toast messages that seamlessly integrate with their app's design.

Pros

  • Highly customizable with numerous styling options
  • Easy to implement and integrate into existing Android projects
  • Supports both Kotlin and Java
  • Regularly maintained and updated

Cons

  • May increase app size slightly due to additional resources
  • Requires some learning curve for advanced customizations
  • Limited to Android platform only

Code Examples

  1. Creating a simple StyleableToast:
StyleableToast.makeText(context, "Hello World!", R.style.myToast).show()
  1. Customizing a StyleableToast programmatically:
StyleableToast.Builder(context)
    .text("Hello World!")
    .textColor(Color.WHITE)
    .backgroundColor(Color.BLUE)
    .show()
  1. Adding an icon to the StyleableToast:
StyleableToast.Builder(context)
    .text("Message sent!")
    .iconStart(R.drawable.ic_sent)
    .show()
  1. Creating a StyleableToast with custom animation:
StyleableToast.Builder(context)
    .text("Animated Toast")
    .stroke(2, Color.BLACK)
    .backgroundColor(Color.WHITE)
    .gravity(Gravity.TOP)
    .solidBackground()
    .textColor(Color.BLACK)
    .iconStart(R.drawable.ic_info)
    .cornerRadius(12)
    .textSize(14)
    .iconSize(24)
    .show()

Getting Started

  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.Muddz:StyleableToast:2.4.0'
}
  1. Add the JitPack repository to your project's build.gradle file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Use StyleableToast in your code:
import io.github.muddz.styleabletoast.StyleableToast

// In your activity or fragment
StyleableToast.makeText(this, "Hello, StyleableToast!", R.style.myToast).show()

Make sure to define your custom toast style in res/values/styles.xml if you're using a predefined style.

Competitor Comparisons

5,515

An Android Alerting Library

Pros of Alerter

  • More customizable with additional features like sound, vibration, and progress bar
  • Supports swipe-to-dismiss functionality
  • Can be displayed at the top or bottom of the screen

Cons of Alerter

  • Larger library size and potentially more complex implementation
  • Limited to displaying alerts at the top or bottom of the screen
  • May require more setup and configuration for basic use cases

Code Comparison

Alerter:

Alerter.create(this@MainActivity)
    .setTitle("Alert Title")
    .setText("Alert text...")
    .setDuration(5000)
    .setBackgroundColorRes(R.color.colorAccent)
    .show()

StyleableToast:

StyleableToast.makeText(context, "Hello World!", Toast.LENGTH_LONG, R.style.myToast).show()

StyleableToast offers a simpler API for basic toast notifications, while Alerter provides more extensive customization options for creating alert-style messages. StyleableToast is more lightweight and easier to implement for simple use cases, whereas Alerter is better suited for applications requiring more complex notification systems with additional features like sound and vibration.

6,569

The usual Toast, but with steroids 💪

Pros of Toasty

  • More customization options for icons and colors
  • Supports custom fonts
  • Includes built-in error, success, and info toast styles

Cons of Toasty

  • Less active development and maintenance
  • Limited animation options compared to StyleableToast
  • Slightly more complex implementation

Code Comparison

StyleableToast:

StyleableToast.makeText(context, "Hello World!", R.style.myToast).show()

Toasty:

Toasty.custom(context, "Hello World!", icon, tintColor, duration, withIcon, shouldTint).show();

Both libraries offer enhanced Toast functionality for Android applications, but they differ in their approach and features. StyleableToast focuses on simplicity and modern design, while Toasty provides more extensive customization options.

StyleableToast has a more active development cycle and offers smoother animations. It also has a simpler API, making it easier to implement for basic use cases. However, Toasty excels in providing pre-built styles for common scenarios like success and error messages, and it allows for more granular control over icon placement and custom fonts.

When choosing between the two, consider your specific requirements for Toast customization and the level of control you need over the appearance and behavior of your Toast messages.

:bread: Make your native android Toasts Tasty

Pros of TastyToast

  • Offers a variety of pre-designed toast styles with animations
  • Includes custom icons and shapes for toasts
  • Easier to implement for developers who prefer ready-made designs

Cons of TastyToast

  • Less customizable compared to StyleableToast
  • Limited to predefined styles and animations
  • Not actively maintained (last update was in 2017)

Code Comparison

TastyToast:

TastyToast.makeText(getApplicationContext(), "Hello World!", TastyToast.LENGTH_LONG, TastyToast.WARNING);

StyleableToast:

new StyleableToast
    .Builder(context)
    .text("Hello World!")
    .textColor(Color.WHITE)
    .backgroundColor(Color.BLUE)
    .show();

StyleableToast offers more flexibility in customizing the toast appearance, allowing developers to set specific colors, fonts, and other attributes. TastyToast, on the other hand, provides a simpler API with predefined styles, making it quicker to implement but less customizable.

While TastyToast offers unique animations and shapes, StyleableToast provides greater control over the toast's appearance and behavior. StyleableToast is also actively maintained, ensuring compatibility with newer Android versions and addressing potential issues.

A library that extends the Android toast framework.

Pros of SuperToasts

  • More customization options, including custom animations and layouts
  • Supports multiple toast types (e.g., button toast, progress toast)
  • Includes a queue manager for handling multiple toasts

Cons of SuperToasts

  • Less actively maintained (last update was several years ago)
  • More complex implementation due to additional features
  • Larger library size, which may impact app performance

Code Comparison

StyleableToast:

StyleableToast.makeText(context, "Hello World!", R.style.myToast).show();

SuperToasts:

SuperToast.create(context, "Hello World!", Style.DURATION_SHORT)
    .setBackground(PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_BLUE))
    .setTextColor(PaletteUtils.getSolidColor(PaletteUtils.WHITE))
    .show();

StyleableToast offers a simpler, more concise implementation for basic toast customization. SuperToasts provides more detailed customization options but requires more code for similar functionality.

Both libraries aim to enhance Android's native toast functionality, with StyleableToast focusing on simplicity and ease of use, while SuperToasts offers a wider range of features at the cost of complexity.

🌈 A Beautiful Motion Toast Library for Kotlin Android

Pros of MotionToast

  • Offers more animation options and customizable motion effects
  • Supports Jetpack Compose for modern Android development
  • Provides a wider range of pre-defined toast styles and icons

Cons of MotionToast

  • May have a steeper learning curve due to more complex customization options
  • Potentially higher performance overhead due to animations and effects
  • Less suitable for simpler toast requirements or projects with minimal UI needs

Code Comparison

StyleableToast:

StyleableToast.makeText(context, "Hello World!", R.style.exampleToast).show()

MotionToast:

MotionToast.createColorToast(this,
    "Hurray success 😍",
    "Upload Completed successfully!",
    MotionToastStyle.SUCCESS,
    MotionToast.GRAVITY_BOTTOM,
    MotionToast.LONG_DURATION,
    ResourcesCompat.getFont(this, R.font.helvetica_regular))

Both libraries offer custom toast functionality, but MotionToast provides more built-in options and animation capabilities out of the box. StyleableToast focuses on simplicity and ease of use, while MotionToast emphasizes rich, animated toast messages with more customization options. The choice between the two depends on the specific project requirements and the desired level of toast customization and visual appeal.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

StyleableToast

APK

An Android library that takes the standard toast to the next level with many styling options. Style your toasts either by code or with a style in styles.xml.

Cases

Example with a style

  1. Define a style in styles.xml. All available attributes:
    <style name="mytoast">
        <item name="stTextBold">true</item>
        <item name="stTextColor">#fff</item>
        <item name="stFont">@font/retrofont</item>
        <item name="stTextSize">14sp</item>
        <item name="stColorBackground">#fff</item>
        <item name="stSolidBackground">true</item>
        <item name="stStrokeWidth">3dp</item>
        <item name="stStrokeColor">#fff</item>
        <item name="stIconStart">@drawable/ic</item>
        <item name="stIconEnd">@drawable/ic</item>
        <item name="stLength">LONG</item> LONG or SHORT
        <item name="stGravity">top</item> top or center
        <item name="stRadius">5dp</item>
    </style>

  1. Pass your style in the static constructor and call show();
    StyleableToast.makeText(context, "Hello World!", Toast.LENGTH_LONG, R.style.mytoast).show();

Example with builder pattern

        new StyleableToast
                .Builder(context)
                .text("Hello world!")
                .textColor(Color.WHITE)
                .backgroundColor(Color.BLUE)
                .show();

Installation

Add the dependency in your build.gradle

dependencies {
    implementation 'io.github.muddz:styleabletoast:2.4.0'   
}

License

Copyright 2016 Muddi Walid

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.