项目作者: nambicompany

项目描述 :
A highly customizable 'speed dial' FloatingActionButton implementation.
高级语言: Kotlin
项目地址: git://github.com/nambicompany/expandable-fab.git
创建时间: 2020-08-04T04:26:36Z
项目社区:https://github.com/nambicompany/expandable-fab

开源协议:MIT License

下载


ExpandableFab

Maven Central
minSdkVersion
Library License

expandable-fab website
The Nambi Company website

A highly customizable Android widget that displays the available actions of a UI via an expandable set of floating action buttons - with optional labels and fluid animations.

Designed to be screen orientation aware, so it can display different elements from portrait to landscape.

Examples

A working Android app filled with some common use cases and customizations of the ExpandableFab widget can be found and built under examples. Below are a few gifs of the widget in use (this isn’t an exhaustive list - the ExpandableFab can do so much more!).

gif of regular ExpandableFab in use
gif showing custom properties
gif of using custom sizes

gif of using multiple ExpandableFabs
gif showing compatibility with BottomAppBar
gif showing compatibility with Snackbar

Usage

Consider reading our Medium articles on what the ExpandableFab is and how to use it if you prefer a more in-depth walkthrough.

Otherwise, simply include the ExpandableFab widget in your project via Gradle (replace X.X.X with the latest version shown here Maven Central):

  1. implementation 'com.nambimobile.widgets:expandable-fab:X.X.X'

or Maven:

  1. <dependency>
  2. <groupId>com.nambimobile.widgets</groupId>
  3. <artifactId>expandable-fab</artifactId>
  4. <version>X.X.X</version>
  5. <type>aar</type>
  6. </dependency>

Then easily add some of the ExpandableFab widget views to your layout like so:

  1. <!-- This is NOT a root view, but should be a child of whatever root view you choose (CoordinatorLayout, ConstraintLayout, etc) -->
  2. <com.nambimobile.widgets.efab.ExpandableFabLayout
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent">
  5. <!-- The next 3 Views will only display in portrait orientation -->
  6. <com.nambimobile.widgets.efab.Overlay
  7. android:layout_width="match_parent"
  8. android:layout_height="match_parent"
  9. app:overlay_orientation="portrait"></com.nambimobile.widgets.efab.Overlay>
  10. <com.nambimobile.widgets.efab.ExpandableFab
  11. android:layout_width="wrap_content"
  12. android:layout_height="wrap_content"
  13. android:layout_gravity="bottom|end"
  14. android:layout_marginBottom="@dimen/ui_margin_medium"
  15. android:layout_marginEnd="@dimen/ui_margin_medium"
  16. android:layout_marginRight="@dimen/ui_margin_medium"
  17. app:efab_orientation="portrait"></com.nambimobile.widgets.efab.ExpandableFab>
  18. <com.nambimobile.widgets.efab.FabOption
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. app:fab_orientation="portrait"
  22. app:label_text="Portrait Option 1"
  23. android:onClick="onClickPortraitOption1"></com.nambimobile.widgets.efab.FabOption>
  24. <!-- The next 3 Views will only display in landscape orientation -->
  25. <com.nambimobile.widgets.efab.Overlay
  26. android:layout_width="match_parent"
  27. android:layout_height="match_parent"
  28. app:overlay_orientation="landscape"></com.nambimobile.widgets.efab.Overlay>
  29. <com.nambimobile.widgets.efab.ExpandableFab
  30. android:layout_width="wrap_content"
  31. android:layout_height="wrap_content"
  32. android:layout_gravity="bottom|end"
  33. android:layout_marginBottom="@dimen/ui_margin_medium"
  34. android:layout_marginEnd="@dimen/ui_margin_medium"
  35. android:layout_marginRight="@dimen/ui_margin_medium"
  36. app:efab_orientation="landscape"></com.nambimobile.widgets.efab.ExpandableFab>
  37. <com.nambimobile.widgets.efab.FabOption
  38. android:layout_width="wrap_content"
  39. android:layout_height="wrap_content"
  40. app:fab_orientation="landscape"
  41. app:label_text="Landscape Option 1"
  42. android:onClick="onClickLandscapeOption1"></com.nambimobile.widgets.efab.FabOption>
  43. </com.nambimobile.widgets.efab.ExpandableFabLayout>

Usage Notes

  • Make sure to include the xmlns:app="http://schemas.android.com/apk/res-auto namespace in each layout file that uses the ExpandableFab widget in order to have access to custom properties.
  • Setting ExpandableFabLayout’s width and height to match_parent will not impede the viewability, clickability or focusability of any other views in your layout (and is needed for children like Overlay who may need the ability to use the full screen).
  • Defining separate widgets for portrait and landscape orientations is not necessary and was done above simply to showcase the widget’s orientation awareness. By default, if you only define one widget, it will automatically be used for both portrait and landscape orientations.
  • Every property in every View within the ExpandableFab widget can be accessed or set programmatically and via XML layout files.
  • None of the customizable properties for the widget Views were set in the example above, so they will all assume their default values automatically.
    • See the library website for a full list of every customizable property for each View, the full Kotlin/Java Docs and many more helpful notes and tips on using the ExpandableFab.

ChangeLog

Please see CHANGELOG.md for a complete account of all changes in each release of this library.

Contributing

Please see CONTRIBUTING.md for information about contributing to this library.

License

  1. MIT License
  2. Copyright (c) 2020 Kelvin Abumere and The Nambi Company
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.