Skip to content

firefinchdev/FABCount

Repository files navigation

FABCount

A better Floating Action Button with a counter badge (at any corner and of any size)

Screenshots

Installation

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Include the library in your build.gradle

dependencies {
    compile 'com.github.firefinchdev:FABCount:c24af3415d'
}

For Maven,

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

<dependency>
	<groupId>com.github.firefinchdev</groupId>
	<artifactId>FABCount</artifactId>
	<version>c24af3415d</version>
</dependency>

Usage & Customization

Directions Available:

TOP_LEFT | TOP_RIGHT | BOTTOM_LEFT | BOTTOM_RIGHT
<com.techno.fabcount.FABCount
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_add_white_24dp" />

and programmatically you can use one of these methods:

FABCount fabCount = findViewById(R.id.fab);
fabCount.setCount(10); 			// Set the count value to show on badge
fabCount.increase(); 			// Increase count by 1
fabCount.decrease(); 			// Decrease count by 1
fabCount.changeTextSize(26);	// Set the counter text size
fabCount.changeTextSize( fabCount.getCurrentSize() + 1);

fabCount.setDirection(FABCount.TOP_LEFT);		// Set counter badge position
fabCount.setDirection(FABCount.TOP_RIGHT);
fabCount.setDirection(FABCount.BOTTOM_LEFT);
fabCount.setDirection(FABCount.BOTTOM_RIGHT);

int dir = fabCount.getDirection();		// Get counter badge direction
int size = fabCount.getCurrentSize();	// Get counter badge text size

The recommended way to customize the background color is by using app:backgroundTint

<com.techno.fabcount.FABCount
        android:id="@+id/counter_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:backgroundTint="#009688"
        android:src="@drawable/ic_add_white_24dp" />

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages