Created
October 26, 2015 13:22
-
-
Save PPartisan/de4efb0e95c5e5c62385 to your computer and use it in GitHub Desktop.
Auto-Hide Behaviour for the Design Support Library FloatingActionButton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sample implementation in Activity class | |
*/ | |
public class MainActivity extends AppCompatActivity { | |
private FloatingActionButton mFloatingActionButton; | |
private FloatingActionButtonBehavior mFloatingActionButtonBehavior; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab); | |
mFloatingActionButtonBehavior = new FloatingActionButtonBehavior(mFloatingActionButton); | |
} | |
@Override | |
public boolean dispatchTouchEvent(MotionEvent ev) { | |
mFloatingActionButtonBehavior.animate(ev); | |
return super.dispatchTouchEvent(ev); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment