Rohan Khajuria
Rohan Khajuria

Reputation: 726

Google's Android Sliding Tabs Layout

I have successfully used Google's Sliding Tabs code in my project. (Sample project can be found here: http://developer.android.com/samples/SlidingTabsBasic/index.html) This is what I have so far: Sliding Tab Layout Screenshot

Unfortunately, I am unable to figure out how to make the tabs take up the entire bar. As shown below, they are taking up only approximately half the screen. I considered changing the padding, but I don't want to hard code it because of varying screen sizes. My ultimate goal is to emulate the tab layout that YouTube uses: YouTube Screenshot

Upvotes: 0

Views: 627

Answers (3)

rookiedev
rookiedev

Reputation: 1127

You probably find the setDistributeEvenly method cannot be resolved if you use the sample code from

http://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html

Then in the createDefaultTabView method of your SlidingTabLayout class, add the following line before returning the textView

textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1.0f));

Upvotes: 0

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

set this property as true in SlidingTabLayout

 mSlidingTabLayout.setDistributeEvenly(true);

Upvotes: 1

Niko Adrianus Yuwono
Niko Adrianus Yuwono

Reputation: 11112

Use Google IO SlidingTabLayout and SlidingTabStrip and call setDistributeEvenly(true) and it will create the same layout as the youtube one

Upvotes: 1

Related Questions