You can set the behavior of the FAB in XML.
For example:
<android.support.design.widget.FloatingActionButton
app:layout_behavior=".MyBehavior" />
Or you can set programmatically using:
CoordinatorLayout.LayoutParams p = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
p.setBehavior(xxxx);
fab.setLayoutParams(p);