makovkastar / FloatingActionButton

[DEPRECATED] Android floating action button
MIT License
4.01k stars 817 forks source link

DEPRECATED

Use the FloatingActionButton from the support library instead.

FloatingActionButton

Android Arsenal

Description

Android floating action button which reacts on scrolling events. Becomes visible when an attached target is scrolled up and invisible when scrolled down.

Demo

Demo

FloatingActionButton Demo on Google Play Store

Integration

1) Add as a dependency to your build.gradle:

dependencies {
    compile 'com.melnykov:floatingactionbutton:1.3.0'
}

2) Add the com.melnykov.fab.FloatingActionButton to your layout XML file. The button should be placed in the bottom right corner of the screen. The width and height of the floating action button are hardcoded to 56dp for the normal and 40dp for the mini button as specified in the guidelines.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:fab="http://schemas.android.com/apk/res-auto"
             android:layout_width="match_parent"
             android:layout_height="match_parent">

    <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    <com.melnykov.fab.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_margin="16dp"
            android:src="https://github.com/makovkastar/FloatingActionButton/raw/master/@drawable/ic_action_content_new"
            fab:fab_colorNormal="@color/primary"
            fab:fab_colorPressed="@color/primary_pressed"
            fab:fab_colorRipple="@color/ripple" />
</FrameLayout>

3) Attach the FAB to AbsListView, RecyclerView or ScrollView :

ListView listView = (ListView) findViewById(android.R.id.list);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.attachToListView(listView);

Check the sample project to see how to use custom listeners if you need to track scroll events.

4) Add the namespace xmlns:fab="http://schemas.android.com/apk/res-auto" to your layout file.

5) Set an icon for the FloatingActionButton using android:src xml attribute. Use drawables of size 24dp as specified by guidelines. Icons of desired size can be generated with Android Asset Studio.

Changelog

Version 1.3.0

Version 1.2.0

Version 1.1.0:

Version 1.0.9:

Version 1.0.8:

Version 1.0.7:

Version 1.0.6:

Thanks to Aidan Follestad.

Version 1.0.5:

Version 1.0.4:

Version 1.0.3:

Applications using FloatingActionButton

Please ping me or send a pull request if you would like to be added here.

Icon Application Icon Application
Finger Gesture Launcher Vocabletrainer
Lanekeep GPS Mileage Tracker Score It
Перезвони мне App Swap
QKSMS - Quick Text Messenger Uninstaller - Beta Version
Device Control Confide
Date Night Jair Player The Music Rainbow
Taskr - Lista de Tareas Festivos: ¡Conoce el mundo!
nowPaper Vicious chain - Don't do that!
My Football Stats The ScoreBoard
NavPoint Just Reminder
Early Notes Ranch - Smart Tip Calculator
Thiengo Calopsita Tinycore - CPU, RAM monitor
Battery Aid Saver & Manager GameRaven
Polaris Office Call Utils
Colorful Note CallSticker - заметки звонка

Links

Country flag icons used in the sample are taken from www.icondrawer.com

License

The MIT License (MIT)

Copyright (c) 2014 Oleksandr Melnykov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.