我想添加額外的間距在標籤小部件的邊上和標籤之間,但填充和邊距似乎沒有任何區別。我也玩過設置分隔線,標籤條左右可繪製,這似乎也沒有任何區別。如何將間距添加到Android中的選項卡小部件?
設法使標籤看起來像這樣:
我想添加額外的間距在標籤小部件的邊上和標籤之間,但填充和邊距似乎沒有任何區別。我也玩過設置分隔線,標籤條左右可繪製,這似乎也沒有任何區別。如何將間距添加到Android中的選項卡小部件?
設法使標籤看起來像這樣:
您需要設置標籤控件之間的分隔符。看看dividers between TabWidgets
谷歌IO計劃應用程序的標籤看起來就像你的。我想看看該應用程序和瀏覽他們的源代碼:http://code.google.com/p/iosched/(中間截圖有標籤)
良好的通話 - 這是一個整潔的外觀應用程序,閱讀源代碼是非常有益的,所以感謝指針。 – Eno 2010-11-13 10:48:27
您可以使用此代碼來做到這一點
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();
是的,我*我*設定在分頻器佈局XML,但它似乎並沒有工作。我試着以你的鏈接建議的方式編程。謝謝。 – Eno 2010-11-13 10:44:30