2010-11-11 40 views

回答

1

您需要設置標籤控件之間的分隔符。看看dividers between TabWidgets

+0

是的,我*我*設定在分頻器佈局XML,但它似乎並沒有工作。我試着以你的鏈接建議的方式編程。謝謝。 – Eno 2010-11-13 10:44:30

1

谷歌IO計劃應用程序的標籤看起來就像你的。我想看看該應用程序和瀏覽他們的源代碼:http://code.google.com/p/iosched/(中間截圖有標籤)

+0

良好的通話 - 這是一個整潔的外觀應用程序,閱讀源代碼是非常有益的,所以感謝指針。 – Eno 2010-11-13 10:48:27

5

您可以使用此代碼來做到這一點

TabWidget widget = getTabWidget(); 
final int tabChildrenCount = widget.getChildCount(); 
LinearLayout.LayoutParams currentLayout; 
for (int i = 0; i < tabChildrenCount; i++) { 
    currentLayout = (LinearLayout.LayoutParams) widget.getChildAt(i).getLayoutParams(); 
    if (i == 0) { 
     currentLayout.setMargins(10, 0, 5, 0); 
    } else if (i == (tabChildrenCount - 1)) { 
     currentLayout.setMargins(5, 0, 10, 0); 
    } else { 
     currentLayout.setMargins(5, 0, 5, 0); 
    } 
    currentLayout.height = 40; 
} 
widget.requestLayout(); 
相關問題