14

I have an action bar with two tabs underneath. It looks alright in most smartphones, but in tablets or the nexus 4, for example, the tabs do not stretch to occupy the whole width of the screen.

Here's a screenshot (taken on a Nexus 4):

enter image description here

As can be seen, there are two black bars to each side of the tabs. I am using action bar sherlock. Is there a way to make tabs occupy full width? some kind of ABS atrribute I can override?

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
LightSystem
  • 193
  • 1
  • 8

5 Answers5

1

I would recommend you use Android Sliding Tab, which is pieces of code from Google to do the same thing as you've shown. Since the 5.0 API, the Action Tab has been deprecated, so this is one good solution to this problem.

Maybe some actually link will be helpful.
Also this in action (Youtube)

DeanK
  • 344
  • 2
  • 14
0

First thing that I would suggest is for you to set the width into fill_parent. Okay well that's kinda obvious I think. Now create a new resource folder named layout-sw600dp then remake all your layouts for tablets. Mostly 7" one. the Android will automatically use the layouts from this folder since it maybe that the screen support is your main problem for this. You can also try reading on this link for more info. Hope it helps. :)

KaHeL
  • 4,301
  • 16
  • 54
  • 78
  • I don't think smartphones (i.e. nexus 4) will be affected by sw600dp resources. I don't really need to support tablets. This might help: [link](http://stackoverflow.com/questions/15100789/how-to-create-different-layout-for-nexus-4-and-similiar-devices-galaxy-s4) – LightSystem Sep 10 '13 at 10:32
0

ABS will use native ActionBar if target SDK 14 or greater. This is a problem (not bug, but feauture) of JB and higher: https://android.googlesource.com/platform/frameworks/base/+/b8139af3dcae80c0030afd0354dc424a7c72c3d9 Possible workaround: set target SDK 15 or lower.

kkeyser
  • 16
0

Use this layout, May be it works:

res/layout-sw600dp/   # For 7” tablets (600dp wide and bigger)

res/layout-sw720dp/ # For 10” tablets (720dp wide and bigger)

res/layout-sw600dp-port/   # For 7” tablets in portrait (600dp wide or                  bigger)

res/layout-sw720dp-port/  # For 10” tablets in portrait (720dp wide or bigger)
-1

Try to use this. Pagersliding tabstrip. it is a custom library.

http://www.androidviews.net/2013/04/pager-sliding-tabstrip/

Github : https://github.com/astuetz/PagerSlidingTabStrip

Ashwin S Ashok
  • 3,623
  • 2
  • 29
  • 36