操作栏选项卡不填充屏幕宽度

时间:2013-05-07 09:54:01

标签: android android-actionbar actionbarsherlock

我有一个操作栏,下方有两个标签。它在大多数智能手机中看起来都不错,但是在平板电脑或nexus 4中,标签不会伸展以占据屏幕的整个宽度。

这是截图(在Nexus 4上拍摄):

enter image description here

可以看出,标签的每一侧都有两个黑条。我正在使用动作栏sherlock。有没有办法让标签占据全宽?某种我可以覆盖的ABS属性?

5 个答案:

答案 0 :(得分:1)

我建议您使用Android Sliding Tab,这是Google提供的代码,与您展示的内容相同。从5.0 API开始,不推荐使用Action选项卡,因此这是解决此问题的一个很好的解决方案。

也许有些actually link会有所帮助。
这也是in action(Youtube)

答案 1 :(得分:0)

我建议的第一件事是将宽度设置为fill_parent。好吧,我觉得这有点明显。现在创建一个名为layout-sw600dp的新资源文件夹,然后重新制作平板电脑的所有布局。大多数是7“one.Android将自动使用此文件夹中的布局,因为屏幕支持可能是您的主要问题。您还可以尝试阅读此link以获取更多信息。希望它有所帮助。: )

答案 2 :(得分:0)

如果目标SDK 14或更高版本,ABS将使用本机ActionBar。 这是JB及更高版本的问题(不是bug,而是feauture): https://android.googlesource.com/platform/frameworks/base/+/b8139af3dcae80c0030afd0354dc424a7c72c3d9 可能的解决方法:设置目标SDK 15或更低版本。

答案 3 :(得分:0)

使用此布局,可能有效:

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)

答案 4 :(得分:-1)

尝试使用此功能。 Pagersliding tabstrip。它是一个自定义库。

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

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