I have an AppBarLayout, ViewPager underneath and a floating action button in one action. I want to animate FAB while scrolling ViewPager. Take a look at the screens below.

When Tab1 is the current tab, FAB should be in the lower right corner. When Tab2 is the current tab, the FAB should be in the lower center area. When Tab3 is the current tab, FAB should return to the lower right corner. When Tab4 is the current tab, the FAB should snap to ImageView4 and should be in the lower right corner of ImageView4.
How can i achieve this? Please help me.
I need to implement onPageChangeListener on the ViewPager and handle the same in onPageScrolled ().
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
final int width = mViewPager.getWidth();
if(position == 0) {
int translationX = (int) ((-(width - mFab.getWidth()) / 2f) * positionOffset);
mFab.setTranslationX(translationX);
mFab.setTranslationY(0);
} else if(position == 1) {
int translationX = (int) (((width - mFab.getWidth())) * positionOffset);
mFab.setTranslationX(translationX);
mFab.setTranslationY(0);
} else if(position == 2) {
}
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
tab1 tab2, FAB , , .
FAB onPageScrolled()?