An Android library for getting a FAB to slide in and out in sync with a scrolling AppBarLayout
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea/copyright Initial import (from https://gist.github.com/strooooke/3ec2a832e3c7bf… Jun 6, 2016
gradle/wrapper
library
sample Remove comment superseded by support library changes Feb 20, 2017
.gitignore Initial import (from https://gist.github.com/strooooke/3ec2a832e3c7bf… Jun 6, 2016
LICENSE Initial commit Jun 6, 2016
README.md Release v0.4 version bump in README and build.gradle Feb 20, 2017
build.gradle Bump support library version to 25.1.1; remove unused dependency Feb 20, 2017
gradle.properties
gradlew Initial import (from https://gist.github.com/strooooke/3ec2a832e3c7bf… Jun 6, 2016
gradlew.bat
settings.gradle Initial import (from https://gist.github.com/strooooke/3ec2a832e3c7bf… Jun 6, 2016

README.md

appbarsyncedfab

An Android library for getting a FAB to slide in and out in sync with a scrolling AppBarLayout.

Appearance

SimpleAppBar ComplexAppBar

Usage

Add as gradle dependency via jitpack.io: Add the JitPack repository in your root build.gradle at the end of repositories:

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

Add the dependency in your app build.gradle file:

	dependencies {
	        compile 'com.github.strooooke:appbarsyncedfab:v0.4'
	}

Add either the behavior to your FAB in XML

<android.support.design.widget.CoordinatorLayout
    ...
  >
  
  <android.support.design.widget.AppBarLayout
    ...
    >
  </android.support.design.widget.AppBarLayout>

  ...

  <android.support.design.widget.FloatingActionButton
    ...
    app:layout_behavior="@string/appbarsyncedfab_fab_behavior"/>

</android.support.design.widget.CoordinatorLayout>

You can also wire up the listener, the CoordinatorLayout, the AppBarLayout and the FAB by hand:

CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 
FabOffsetter fabOffsetter = new FabOffsetter(coordinatorLayout, fab);
appBarLayout.addOnOffsetChangedListener(fabOffsetter);

This way is not recommended; you will lose proper interaction with the snackbar.

License

Copyright 2016 Juliane Lehmann <jl@lambdasoup.com>

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.