请在动作条滚动标签时达到极限,而不是创建一个下拉列表 [英] Make Tabs on ActionBar scroll when reach limit, rather than create a dropdown-list

查看:135
本文介绍了请在动作条滚动标签时达到极限,而不是创建一个下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所暗示的,我有一个Android 4.0的平板电脑的应用程序,使用该动作条和标签模式。

As the title suggests, I have an Android 4.0 Tablet app, that uses the Actionbar and tab mode.

如果我添加任何超过4个或5个选项卡的操作栏,下拉列表就创建。我已阅读文档,其中指出,注意:在某些情况下,Android系统将显示以保证操作栏中最适合你的动作条的标签作为一个下拉列表。

If I add any more than 4 or 5 tabs to the action bar, a dropdown list is created instead. I have read the documentation, which states, "Note: In some cases, the Android system will show your action bar tabs as a drop-down list in order to ensure the best fit in the action bar."

只是想知道是否有可能重写默认行为,并获得动作条滚动的项目?设计文件<一个href="http://developer.android.com/design/patterns/actionbar.html">http://developer.android.com/design/patterns/actionbar.html关于滚动标签谈判,但我似乎无法找到他们比在设计文件中的其他任何信息。

Was just wondering if it is possible to override the default behavior and get the actionbar to scroll the items? The design document http://developer.android.com/design/patterns/actionbar.html talks about scrollable tabs, but I can't seem to find any information on them other than in the design document.

推荐答案

我一直在努力得到这个工作。然而,随着ActionBarSherlock打之后,溶液是僵硬容易。如果你下载的造型设计样品来源,并期待在MainActivity类,你可以看到它创建并添加标签,并下了:

I have been struggling to get this to work. However, after playing with ActionBarSherlock, the solution is infuriatingly easy. If you download the sample Styled source and look in the MainActivity class, you can see it create and add the tabs, and beneath that:

actionBar.setDisplayShowTitleEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

我以前添加的标签叫这些了,我的卡已经变成了下拉列表。事实证明,所有你需要做的是添加标签,而不是保持滚动标签后给他们打电话。

I had called these BEFORE adding the tabs, and my tabs had been turned into a drop-down list. Turns out, all you need to do is call them after adding the tabs instead to keep the scrolling tabs.

这篇关于请在动作条滚动标签时达到极限,而不是创建一个下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆