我想设计一个页面,我只想显示一个标签。但是当我只添加一个选项卡时,它会占用可用的全宽,但我希望该选项卡只占用很小的空间,剩余空间留空。我不想添加其他标签。始终只显示一个选项卡。代码如下
public class TabViewActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, FirstTab.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("firstTab").setIndicator("First Tab")
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(1);