title: How to make the FAB avoid being moved in ViewPager, yet be a part of the fragment within?
body: <h2>Background</h2>
  
  <p>According to the material design guidelines (<a href="https://www.google.com/design/spec/components/buttons-floating-action-button.html#buttons-floating-action-button-behavior" rel="noreferrer"><strong>here</strong></a>), if you use a ViewPager that has a FAB (floating action button) for the fragments within, the FAB shouldn't move as a part of the fragments, but either disappear or be replaced by another, or animate to something else.</p>
  
  <p>In short, instead of this:</p>
  
  <p><a href="https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B6Okdz75tqQsNVRkV3FZMktvMWc/components-buttons-fab-behavior_06_xhdpi_009.webm" rel="noreferrer">https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B6Okdz75tqQsNVRkV3FZMktvMWc/components-buttons-fab-behavior_06_xhdpi_009.webm</a></p>
  
  <p>you should do this:</p>
  
  <p><a href="https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B6Okdz75tqQsVlhxNGJCNTEzNFU/components-buttons-fab-behavior_04_xhdpi_009.webm" rel="noreferrer">https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B6Okdz75tqQsVlhxNGJCNTEzNFU/components-buttons-fab-behavior_04_xhdpi_009.webm</a></p>
  
  <h2>The problem</h2>
  
  <p>I don't see any example or tutorial of what's the best way to perform this. </p>
  
  <p>I mean, having a FAB for each fragment (or some of them) in the ViewPager, while each will be controlled by its fragment (logic and how it looks), yet the FAB won't really move as part of the fragment while sliding between the fragments in the ViewPager.</p>
  
  <p>Even as example apps, I don't see this behavior anywhere. The contacts app has the same FAB for both fragments, and the dialer has the FAB just moving. </p>
  
  <p>There are even apps that use the bad behavior (like Solid-Explorer). On YouTube, there is a FAB (on the "Account" fragment), but it's on the header, so it might be ok there.</p>
  
  <h2>The question</h2>
  
  <p>How should you implement the correct behavior? Would you really put the FAB as a part of the activity instead of the fragments? </p>
  
  <p>Is there maybe a tutorial and/or sample about this ?</p>
  
  <p>Maybe, when the ViewPager starts scrolling, I could detach the FAB, and attach it to the activity, animate while being scrolled, and when it's done scrolling, I could hide it and show the one of the other fragment?</p>