here is a sample solution :
implement the ViewPager.OnPageChangeListener
in your activity or your fragment where you use the ViewPager
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int tabStripChildCount = mTabStrip.getChildCount();
for (int i=0 ; i < tabStripChildCount ; i++){
View view = mTabStrip.getChildAt(i);
ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
p.setMargins(0, 0, 50, 0);
view.requestLayout();
}
}
mTabStrip is the table layout in your activity or fragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
View view = inflater.inflate(R.layout.patient_activity__fragment_tab_viewer, container, false);
mViewPager = (ViewPager) view.findViewById(R.id.viewPager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mTabStrip = (SlidingTabLayout) view.findViewById(R.id.tabs);
mTabStrip.setViewPager(mViewPager);
return view;
}
finally you will have a margin between your title fragments