Manuel Castro
Manuel Castro

Reputation: 1723

SlidingTabLayout setDistributeEvenly missing

I'm using the SlidingTabLayout.java from developers android page. Before I used slidingTabLayout.setDistributeEvenly(true); to center the slidingtab but now the method is missing. What's the alternative? I could use the old java class but I suppose there is an alternative method to do the same thing.

Upvotes: 2

Views: 1216

Answers (1)

user1801060
user1801060

Reputation: 2821

In your SlidingTabLayout add the following:

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f);
tabView.setLayoutParams(lp);

just before

mTabStrip.addView(tabView);

After that you won't even need slidingTabLayout.setDistributeEvenly(true); the tabs will automatically center themselves.

Upvotes: 9

Related Questions