2

我想在选项卡小部件的侧面和选项卡之间添加额外的间距,但填充和边距似乎没有任何区别。我还尝试设置分隔线、标签条左右可绘制对象,这似乎也没有任何区别。

试图使标签看起来像这样: 替代文字

4

3 回答 3

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();
于 2012-10-17T10:03:33.193 回答
1

Google IO 计划应用程序的标签与您的一模一样。我会检查那个应用程序并浏览他们的源代码:http ://code.google.com/p/iosched/ (中间的屏幕截图有标签)

于 2010-11-11T16:32:49.440 回答
1

您需要设置 Tab 小部件之间的分隔线。看看TabWidgets 之间的分隔线

于 2010-11-11T15:40:50.940 回答