title: Translate Floating Action Button on ViewPager scroll
body: <p>I have a screen with 3 tabs, a ViewPager below with 3 Fragments and a Floating Action Button in bottom-right corner.</p>
  
  <p>When 1st tab is current tab then I want to show the FAB in bottom-right corner. When 2nd tab is current tab then I want to show the FAB in bottom-centre. When 3rd tab is current tab then I want to hide the FAB.</p>
  
  <p>The translate animation from bottom-right to bottom-centre or vice versa should happen as the view pager scrolls i.e. on the basis of scroll amount.</p>
  
  <p>Below is what I have tried.</p>
  
  <pre><code>mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
              ViewCompat.animate(mFAB)
                      .translationX(-translate)
                      .withLayer()
                      .setDuration(0)
                      .setInterpolator(new LinearInterpolator())
                      .start();
          }
  
          @Override
          public void onPageSelected(int position) {
              mTabLayout.getTabAt(position).select();
          }
  
          @Override
          public void onPageScrollStateChanged(int state) {
  
          }
      });
  </code></pre>
  
  <p>Is this the best way to do this? If yes what should be the value of translate variable?</p>
  
  <p>Please help me in implementing this.</p>
  
  <p>For reference you can checkout Android Lollipop Call application. The FAB to show the dialer animates in similar manner. For 1st tab its in bottom-right then for middle tab it comes in the centre. This is exactly what I want.</p>