• Stars
    star
    1,552
  • Rank 29,146 (Top 0.6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A toolbar that morphs from a FloatingActionButton

FloatingToolbar

A toolbar that morphs from a FloatingActionButton

Inspired by the material design spec: https://www.google.com/design/spec/components/buttons-floating-action-button.html#buttons-floating-action-button-transitions

Available from API 14.

How to use

1. Add the following to your build.gradle:
compile 'com.github.rubensousa:floatingtoolbar:1.5.1'
2. Add FloatingToolbar as a direct child of CoordinatorLayout and before the FloatingActionButton:
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    
    <!-- Appbar -->

    <com.github.rubensousa.floatingtoolbar.FloatingToolbar
        android:id="@+id/floatingToolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom"
        app:floatingMenu="@menu/main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_share_black_24dp" />
        
        
</android.support.design.widget.CoordinatorLayout>
3. Specify a menu resource file or custom layout with app:floatingMenu or app:floatingCustomView

You can also build a menu programmatically using FloatingToolbarMenuBuilder:

 mFloatingToolbar.setMenu(new FloatingToolbarMenuBuilder(this)
                .addItem(R.id.action_unread, R.drawable.ic_markunread_black_24dp, "Mark unread")
                .addItem(R.id.action_copy, R.drawable.ic_content_copy_black_24dp, "Copy")
                .addItem(R.id.action_google, R.drawable.ic_google_plus_box, "Google+")
                .addItem(R.id.action_facebook, R.drawable.ic_facebook_box, "Facebook")
                .addItem(R.id.action_twitter, R.drawable.ic_twitter_box, "Twitter")
                .build());
4. Attach the FAB to the FloatingToolbar to automatically start the transition on click event:
mFloatingToolbar.attachFab(fab);
5. Set a click listener
mFloatingToolbar.setClickListener(new FloatingToolbar.ItemClickListener() {
            @Override
            public void onItemClick(MenuItem item) {
                
            }

            @Override
            public void onItemLongClick(MenuItem item) {

            }
        });
6. If you want to show a snackbar in the same layout as the FloatingToolbar, please use:
mFloatingToolbar.showSnackBar(snackbar);
7. (Optional) Attach a RecyclerView to hide the FloatingToolbar on scroll:
mFloatingToolbar.attachRecyclerView(recyclerView);
8. (Optional) Use show() and hide() to trigger the transition anytime:
mFloatingToolbar.show();
mFloatingToolbar.hide();
9. (Optional) Add a MorphListener to listen to morph animation events
mFloatingToolbar.addMorphListener(new FloatingToolbar.MorphListener() {
    @Override
    public void onMorphEnd() {
        
    }

    @Override
    public void onMorphStart() {

    }

    @Override
    public void onUnmorphStart() {

    }

    @Override
    public void onUnmorphEnd() {

    }
});

Attributes

  • app:floatingToastOnLongClick -> boolean. Defaults to true
  • app:floatingHandleFabClick -> boolean. Defaults to true
  • app:floatingMenu -> Menu resource
  • app:floatingItemBackground -> Drawable resource
  • app:floatingCustomView -> Layout resource
  • app:floatingAutoHide -> boolean. Defaults to true

Apps using FloatingToolbar (Send a PR to add your app here)

License

Copyright 2016 Rúben Sousa

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

GravitySnapHelper

A SnapHelper that snaps a RecyclerView to an edge.
Java
4,985
star
2

ViewPagerCards

ViewPager cards inspired by Duolingo
Java
4,063
star
3

PreviewSeekBar

A SeekBar suited for showing a preview of something. As seen in Google Play Movies.
Java
3,423
star
4

BottomSheetBuilder

A simple library that creates BottomSheets according to the Material Design specs
Java
559
star
5

Decorator

Decorator is an Android library that helps creating composable margins and dividers in RecyclerViews
Kotlin
531
star
6

RaiflatButton

A raised button that lowers down to 0dp of elevation
Java
331
star
7

RecyclerViewNestedExample

From: https://rubensousa.com/2019/08/16/nested_recyclerview_part1/ and https://rubensousa.com/2019/08/27/saving_scroll_state_of_nested_recyclerviews/
Kotlin
166
star
8

BottomSheetExample

A sample project with the new BottomSheet classes from the android support library
Java
129
star
9

Transitions

A sample that showcases some transitions
Java
118
star
10

DpadRecyclerView

A RecyclerView built for Android TV as a replacement for Leanback's BaseGridView.
Kotlin
87
star
11

SlidingTabs

Tabs created with the new android.support.design.widget.TabLayout
Java
25
star
12

StackView

A view that arranges its children in the form of a stack
Java
16
star
13

lista

Lista helps you building composable sections and nested lists in RecyclerViews.
Kotlin
14
star
14

LoadMoreAdapter

A RecyclerView adapter that offers support to loading more items
Java
9
star
15

AndroidGithubPackage

Sample Android library that's published to GitHub Packages using a GitHub Action
Java
4
star
16

FragmentContainerViewIssue

https://issuetracker.google.com/issues/146359827
Kotlin
3
star
17

TabLayoutAdapter

A helper library to easily create tabs with TabLayout
Java
3
star
18

NavigationViewExample

An example app with NavigationView of the android.support.design library
Java
3
star
19

CropView

A simple view that selects an area for cropping
Java
3
star
20

WorkManagerKitkatBug

https://issuetracker.google.com/issues/122578012
Kotlin
2
star
21

rubensousa.github.io

SCSS
2
star
22

WorkManagerConcurrent

https://issuetracker.google.com/issues/121345393
Kotlin
1
star
23

Mieti

Aplicação para o cálculo da média do Mestrado Integrado em Engenharia de Telecomunicações e Informática da Universidade do Minho.
Java
1
star
24

adventofcode2017

Solutions for Advent of Code
Kotlin
1
star
25

StateSaverIssue

Java
1
star