Convert Figma logo to code with AI

zendesk logoandroid-floating-action-button

Floating Action Button for Android based on Material Design specification

6,379
1,460
6,379
157

Top Related Projects

Floating Action Button for Android based on Material Design specification

A multi-functional FAB component with customizable options

Quick Overview

The zendesk/android-floating-action-button repository is an Android library that provides an implementation of the Floating Action Button (FAB) component from Material Design. It offers a customizable and easy-to-use FAB with additional features like labels and multiple actions.

Pros

  • Easy integration with Android projects
  • Customizable appearance and behavior
  • Supports multiple actions with labels
  • Compatible with older Android versions

Cons

  • Not actively maintained (last update was in 2018)
  • May not include the latest Material Design guidelines
  • Limited documentation and examples
  • Potential compatibility issues with newer Android versions

Code Examples

  1. Basic FAB implementation:
val fab = FloatingActionButton.Builder(this)
    .setContentView(ImageView(this).apply {
        setImageResource(R.drawable.ic_add)
    })
    .build()
  1. FAB with label:
val labeledFab = FloatingActionButton.Builder(this)
    .setContentView(ImageView(this).apply {
        setImageResource(R.drawable.ic_edit)
    })
    .setBackgroundDrawable(R.drawable.button_action_red_selector)
    .setPosition(FloatingActionButton.POSITION_TOP_RIGHT)
    .setLabelText("Edit")
    .build()
  1. Multiple action menu:
val menuBuilder = FloatingActionMenu.Builder(this)

val actions = listOf(
    FloatingActionButton.Builder(this)
        .setContentView(ImageView(this).apply {
            setImageResource(R.drawable.ic_edit)
        })
        .build(),
    FloatingActionButton.Builder(this)
        .setContentView(ImageView(this).apply {
            setImageResource(R.drawable.ic_delete)
        })
        .build()
)

menuBuilder.addSubActionView(actions[0])
    .addSubActionView(actions[1])
    .attachTo(mainFab)
    .build()

Getting Started

  1. Add the JitPack repository to your project's build.gradle:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app's build.gradle:
dependencies {
    implementation 'com.github.zendesk:android-floating-action-button:v1.10.1'
}
  1. Sync your project and start using the FloatingActionButton in your layouts or code.

Competitor Comparisons

Floating Action Button for Android based on Material Design specification

Pros of android-floating-action-button

  • Identical functionality and features
  • Same implementation and codebase
  • Consistent user experience across both repositories

Cons of android-floating-action-button

  • No unique advantages over the other repository
  • Potential confusion due to duplicate repositories
  • Redundant maintenance efforts

Code Comparison

Both repositories contain identical code, so there are no differences to highlight. Here's a sample of the shared code:

public class FloatingActionButton extends ImageButton {
    private static final int SHADOW_HORIZ_OFFSET_DEFAULT = 0;
    private static final int SHADOW_VERT_OFFSET_DEFAULT = 0;
    private static final int SHADOW_RADIUS_DEFAULT = 4;
    private static final int SHADOW_COLOR_DEFAULT = 0x66000000;
    // ... (rest of the code is identical)
}

Summary

The comparison between android-floating-action-button and android-floating-action-button reveals that they are essentially the same repository. Both provide a floating action button implementation for Android applications with identical features, codebase, and user experience. The main drawback is the redundancy of having two identical repositories, which may lead to confusion and unnecessary maintenance efforts. Users can choose either repository interchangeably without any functional differences.

A multi-functional FAB component with customizable options

Pros of faboptions

  • More customizable with additional animation options
  • Supports multiple FAB options in a single component
  • Easier integration with modern Android development practices

Cons of faboptions

  • Less mature and potentially less stable than android-floating-action-button
  • Fewer stars and contributors, indicating a smaller community
  • May have limited documentation and support compared to the Zendesk project

Code Comparison

faboptions:

val fabOptions = findViewById<FabOptions>(R.id.fab_options)
fabOptions.setButtonsMenu(R.menu.menu_fab_options)
fabOptions.setOnClickListener { view ->
    when (view.id) {
        R.id.faboptions_favorite -> // Handle favorite action
        R.id.faboptions_textsms -> // Handle textsms action
        R.id.faboptions_download -> // Handle download action
    }
}

android-floating-action-button:

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setIcon(R.drawable.ic_fab_star);
fab.setColorNormalResId(R.color.pink);
fab.setColorPressedResId(R.color.pink_pressed);
fab.setOnClickListener(view -> // Handle click action);

The faboptions library offers a more concise way to handle multiple FAB options, while android-floating-action-button provides a simpler approach for single FAB implementations. faboptions uses Kotlin, which aligns with modern Android development trends, whereas android-floating-action-button uses Java.

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

FloatingActionButton

Yet another library for drawing Material Design promoted actions.

Features

  • Support for normal 56dp and mini 40dp buttons.

    Demo

  • Customizable background colors for normal and pressed states and icon drawable.

    Demo

  • Convenience AddFloatingActionButton class with plus icon drawn in code.

  • FloatingActionsMenu which can be expanded/collapsed to reveal multiple actions.

    Demo

  • Optional labels for buttons in FloatingActionsMenu.

    Demo

Usage

Just add the dependency to your build.gradle:

dependencies {
    compile 'com.getbase:floatingactionbutton:1.10.1'
}

To see how the buttons are added to your xml layouts, check the sample project.

Caveats

The API is extremely limited at the moment. It solves few select use cases in the app I'm working on.

Unlike some other FloatingActionButton libraries this library doesn't implement "quick return" pattern, i.e. hiding the button on scrolling down and showing it on scrolling up. That's intentional, I think that should be responsibility of another component, not the button itself.

This library is minSdkVersion=14 and if that changes, the version number will be increased, not decreased. It means that Honeycomb, Gingerbread or - gods forbid - Froyo, won't ever be supported. I won't even consider merging pull requests fully implementing support for older versions. We need to move on as Android community and focus on delivering value for 95% of users of modern Android OS instead of jumping through burning hoops to support ancient devices with ancient OS.

If you really require support for older Android versions, str4d maintains a version of this library with minSdkVersion=4.

Credits

I used FloatingActionButton library by Oleksandr Melnykov as a base for development.

Copyright and license

Copyright 2014 Zendesk

Licensed under the Apache License, Version 2.0