2010-11-11 66 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(); 
相关问题