BadgeGenerator is a lightweight Android library that allows developers to create, customize, and display status badges (inspired by Shields.io) directly within their mobile applications.
- Custom Styles: Support for
for-the-badge,plastic,flat,flat-square, andsocialstyles. - Logo Support: Integrated support for Simple Icons and custom Base64 logos.
- Interactive: Built-in support for redirect links on badge clicks.
- Export Options: Download your generated badges as PNG or SVG files.
- Smart Conversion: Utility class to convert Bitmaps, Uris, and Files to Base64 strings.
- Ultra-Lightweight: Total library size is only ~9KB.
Sample.mp4
For a step-by-step walkthrough, check out the YouTube Tutorial.
(Note: Video may not cover the latest v2.2 features).
Add the JitPack repository to your settings.gradle:
dependencyResolutionManagement {
repositories {
maven { url '[https://jitpack.io](https://jitpack.io)' }
}
}Add the following to your app-level build.gradle:
dependencies {
implementation 'com.github.sambhav2358:BadgeGenerator:2.2'
}Alternatively, you can manually include the .aar file.
Declare the BadgeView in your layout file:
<com.sambhav2358.badgegeneratorlibrary.BadgeView
android:id="@+id/badge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:badgeLabel="Status"
app:badgeMessage="Active"
app:logoImage="whatsapp"
app:logoWidth="25"
app:redirectUrl="[https://github.com](https://github.com)" />Configure the badge dynamically through code:
// Basic Configuration
binding.badge.setLabel("Build");
binding.badge.setMessage("Passing");
binding.badge.setColor(BadgeColor.brightGreen);
binding.badge.setType(BadgeType.flat);
// Advanced Customization
binding.badge.setLabelColor("#2F2F2F"); // Set background for the label side
binding.badge.setLogo("android"); // Uses SimpleIcons slugs
binding.badge.setLink("[https://github.com/sambhav2358](https://github.com/sambhav2358)");
| Supported Badge Styles | Style Preview |
|---|---|
| for-the-badge | ![]() |
| plastic | ![]() |
| flat | ![]() |
| flat-square | ![]() |
| Social | ![]() |
You can use standard slugs from Simple Icons or provide your own:
// Using a custom Base64 logo
binding.badge.setCustomLogo(Base64Converter.getBase64FromBitmap(myBitmap));
// Changing logo color and width
binding.badge.setLogoColor(BadgeColor.yellow);
binding.badge.setLogoWidth("30");Save your generated badge directly to the device storage:
// Download as SVG
binding.badge.downloadBadgeSVG(Environment.DIRECTORY_PICTURES);
// Download as PNG
binding.badge.downloadBadgePNG(Environment.DIRECTORY_PICTURES);If you already have a Shields.io URL, you can load it directly:
binding.badge.loadFromUrl("[https://img.shields.io/badge/dynamic/json](https://img.shields.io/badge/dynamic/json)?...");Image Quality: When using non-vector custom logos, converting to SVG is not possible. In these cases, the badge defaults to PNG, which may result in quality loss at higher scales.
XML Colors: Background color modification is currently only supported via Java/Kotlin code.
Shields.io β For the badge design inspiration.
Picasso & GlideToVectorYou β For image loading.
This project is open-source and free to use/modify under the MIT License.
Built with β€οΈ by Sambhav Khandelwal




