Actionbarsherlock中的标签总是在操作栏内?(Tabs in Actionbarsherlock are always inside the actionbar?)

编程入门 行业动态 更新时间:2024-10-11 17:26:50
Actionbarsherlock中的标签总是在操作栏内?(Tabs in Actionbarsherlock are always inside the actionbar?)

我正在运行来自Actionbersherlock示例的演示,并注意到标签总是位于操作栏内,如图所示。 我该如何解决? 日Thnx。

public class TabNavigation extends SherlockActivity implements ActionBar.TabListener { private TextView mSelected; @Override public void onCreate(Bundle savedInstanceState) { setTheme(SampleList.THEME); //Used for theme switching in samples super.onCreate(savedInstanceState); setContentView(R.layout.tab_navigation); mSelected = (TextView)findViewById(R.id.text); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (int i = 1; i <= 3; i++) { ActionBar.Tab tab = getSupportActionBar().newTab(); tab.setText("Tab " + i); tab.setTabListener(this); getSupportActionBar().addTab(tab); } } @Override public void onTabReselected(Tab tab, FragmentTransaction transaction) { } @Override public void onTabSelected(Tab tab, FragmentTransaction transaction) { mSelected.setText("Selected: " + tab.getText()); } @Override public void onTabUnselected(Tab tab, FragmentTransaction transaction) { }

}

代码从这里:

https://github.com/JakeWharton/ActionBarSherlock/blob/master/actionbarsherlock-samples/demos/src/com/actionbarsherlock/sample/demos/TabNavigation.java

I was running the demo from Actionbersherlock samples and noticed the tabs were always inside the actionbar as in the picture. How do I fix this? thnx.

public class TabNavigation extends SherlockActivity implements ActionBar.TabListener { private TextView mSelected; @Override public void onCreate(Bundle savedInstanceState) { setTheme(SampleList.THEME); //Used for theme switching in samples super.onCreate(savedInstanceState); setContentView(R.layout.tab_navigation); mSelected = (TextView)findViewById(R.id.text); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (int i = 1; i <= 3; i++) { ActionBar.Tab tab = getSupportActionBar().newTab(); tab.setText("Tab " + i); tab.setTabListener(this); getSupportActionBar().addTab(tab); } } @Override public void onTabReselected(Tab tab, FragmentTransaction transaction) { } @Override public void onTabSelected(Tab tab, FragmentTransaction transaction) { mSelected.setText("Selected: " + tab.getText()); } @Override public void onTabUnselected(Tab tab, FragmentTransaction transaction) { }

}

Code From here:

https://github.com/JakeWharton/ActionBarSherlock/blob/master/actionbarsherlock-samples/demos/src/com/actionbarsherlock/sample/demos/TabNavigation.java

最满意答案

根据操作栏选项卡指南 :

系统根据不同的屏幕尺寸调整操作栏选项卡 - 当屏幕足够宽时将它们放置在主操作栏中,或者当屏幕太窄时将其放置在单独的栏(称为“堆叠操作栏”)中

由于ActionBarSherlock模仿平台行为,如果有足够的空间,选项卡将显示在操作栏中。 您无法按其他 答案强制堆叠操作栏模式。

Per the Action Bar Tabs guide:

the system adapts the action bar tabs for different screen sizes—placing them in the main action bar when the screen is sufficiently wide, or in a separate bar (known as the "stacked action bar") when the screen is too narrow

As ActionBarSherlock mimics the platform behavior, tabs will appear in the Action Bar if there is enough space. You cannot force the stacked action bar pattern as per other answers.

更多推荐

本文发布于:2023-04-29 09:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335632.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是在   栏内   标签   操作   Actionbarsherlock

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!