Skip to content

Repository files navigation

Fabb

Custom floating action button with animation and the option to add up to 3 action buttons.

fabbb


If you want to thank me for this library, you can do so below:

Buy Me A Coffee


Demo:

The demo app can be downloaded here

Fbb

Implement Fabb into your project:

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

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

Add the dependency to your app level build.gradle

dependencies {
implementation 'com.github.HBiSoft:Fabb:0.0.1'
}

Using Fabb library:

publicclassMainActivityextendsAppCompatActivity {
//Declare FabbFabbfabb;
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize Fabbfabb = findViewById(R.id.fabb);
}
}

Set event listeners:

fabb.setEventListener(newFabbListener() {
@OverridepublicvoidonFabbOpened() {
//Fabb was opened
}
@OverridepublicvoidonFabbClosed() {
//Fabb was closed
}
@OverridepublicvoidonFabbMainPressed() {
//Main Fabb was pressed
}
@OverridepublicvoidonFabbActionOnePressed() {
//Action button one was pressed//This is the action button above the main Fabb
}
@OverridepublicvoidonFabbTwoPressed() {
//Action button two was pressed
}
@OverridepublicvoidonFabbThreePressed() {
//Action button three was pressed//This is the action button at the top
}
});

Customisation:

This can be done in xml or in java.

If you set this in java and in xml, then java will be favoured

Java:

// Set number of action buttons (up to 3) - defaults to 0fabb.setNumberOfActions(3);
// Set custom fontfabb.setCustomFont(Typeface.createFromAsset(getAssets(), "fonts/YourFont.otf"));
// Set main Fabb backgroundfabb.setMainFabBackgroundColor(getResources().getColor(R.color.colorPrimary));
// Set main Fabb iconfabb.setMainFabIcon(getResources().getDrawable(R.drawable.ic_mail_white_24dp));
// Set main Fabb color when openedfabb.setMainFabonOpenedColor(getResources().getColor(R.color.colorPrimary));
// Set action buttons textfabb.setActionOneText("Email");
fabb.setActionTwoText("Call");
fabb.setActionThreeText("Video Call");
// Set all action buttons background colorfabb.setAllActionsBackground(getResources().getColor(R.color.colorPrimary));
// Set background for spesific action buttonfabb.setActionOneBackgroundColor(R.drawable.ic_mail_white_24dp);
fabb.setActionTwoBackgroundColor(R.drawable.ic_mail_white_24dp);
fabb.setActionThreeBackgroundColor(R.drawable.ic_mail_white_24dp);
// Set action buttons iconfabb.setActionOneIcon(R.drawable.ic_mail_white_24dp);
fabb.setActionTwoIcon(R.drawable.ic_call_white_24dp);
fabb.setActionThreeIcon(R.drawable.fab_cam);
// Keep Fabb open until close button is pressedfabb.dismissOnOutsideClicked(false);
// Check if Fabb is open (returns boolean)fabb.isOpen();

xml:

// Set number of action buttons (up to 3) - defaults to 0app:setNumberOfActions="3"// Set background for spesific action buttonapp:setActionOneBackgroundColor="#b51a2d"app:setActionTwoBackgroundColor="#b51a2d"app:setActionThreeBackgroundColor="#b51a2d"// Set main Fabb backgroundapp:setMainFabBackgroundColor="#0094de"// Set main Fabb iconapp:setMainIcon="@drawable/ic_close_black_24dp"// Set main Fabb color when openedapp:setMainFabOpenedColor="@android:color/white"// Set action button textapp:setActionOneText="Some Text"app:setActionTwoText="Some Text"app:setActionThreeText="Some Text"// Set action button iconapp:setActionOneIcon="@drawable/ic_close_black_24dp"app:setActionTwoIcon="@drawable/ic_close_black_24dp"app:setActionThreeIcon="@drawable/ic_close_black_24dp"

About

Custom floating action button Android library

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages