我正在运行 Actionbersherlock 示例中的演示,并注意到选项卡始终位于操作栏内,如图所示。我该如何解决? 谢谢。
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
最佳答案
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
由于 ActionBarSherlock 模仿平台行为,如果有足够的空间,选项卡将出现在操作栏中。您不能按照 other 强制堆叠操作栏模式answers .
关于android - Actionbarsherlock 中的选项卡总是在操作栏内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16863594/