I am using Google\'s SlidingTabLayout. As i only have 3 tabs to be displayed, I am seeing empty space after last tab.
Please screenshot below.
You can create a custom tab layout and assign it to your SlidingTabLayout to inflate.
custom_tab.xml:
In your code:
viewPager = (ViewPager) rootView.findViewById(R.id.viewPager);
viewPager.setAdapter(new SampleAdapter(getChildFragmentManager()));
SlidingTabLayout tabLayout = (SlidingTabLayout)rootView.findViewById(R.id.slidingTab);
tabLayout.setCustomTabView(R.layout.custom_tab,R.id.customText);
tabLayout.setViewPager(viewPager);
By keeping the width to 0 dp and the weight as 1 (the number is arbitrary), the layout should take care of giving all your tabs equal screen space. This should also work for any number of tabs. You shouldn't need to modify your SlidingTabLayout.java.