2013-11-22 36 views
0

這裏是我的代碼。我是新手可以有人請幫助我如何顯示imageIcon中心就像測試出現在中心請讓我知道如何自定義標籤欄圖像使用android。如何使用android設置標籤欄圖像的中心選項卡?

protected void onCreate(Bundle savedInstanceState) { 
       super.onCreate(savedInstanceState); 
       ActionBar bar = getActionBar(); 
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); 
      bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO); 
      String headerName[] = {"Info","Location","Discipline","Summary","Status", "Plus"}; 
      //int headerName[]={R.drawable.info,R.drawable.location,R.drawable.discipline,R.drawable.summary,R.drawable.status, R.drawable.plus}; 
      Log.i("log ", "1"); 
      for (int i=0; i < headerName.length; i++) { 

        Tab tab = bar.newTab();       
        // tab.setText(headerName[i]); 
       tab.setIcon(R.drawable.info); 

        tab.setTabListener(this); 
        bar.addTab(tab); 
        Log.i("log ", "" +i); 
      } 
    } 

present output

最終標籤欄圖像應顯示以及在中心標籤欄的藍線及以上。 圖像應該顯示爲與屏幕上顯示的標籤欄文本相同 請幫助我如何製作自定義標籤欄圖像?

text tab bar

回答

0
+0

我不使用tabHOST我想通過動作條酒吧= getActionBar()做; Tab tab = bar.newTab(); tab.setText(headerName [i]); // tab.setIcon(R.drawable.info); – nida

+0

它應該比使用tabhost更容易。你試過這個: http://developer.android.com/reference/android/app/ActionBar.Tab.html#setCustomView(int)? –

相關問題