我想設計一個頁面,我只想顯示一個選項卡。但是,當我只添加一個選項卡,它需要全部可用的寬度,但我希望該選項卡只佔用較小的空間,剩餘空間留空。沒有其他標籤我想添加。一次只顯示一個選項卡。代碼如下android中的自定義tabview
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);
感謝我嘗試這樣做,這是工作 – Vikas