我有一个带有4个标签的简单tabController,但我希望图标图像占据整个标签。我还希望选项卡的文本位于图标图像上方。我只需要一些提示即可朝正确的方向前进。

我无法发布标签页外观的图像(信誉得分不足)。但基本上,我需要掌握选项卡图标周围的所有填充。

我的图标是png文件。我的tabControllerView正在扩展TabActivity,并且我正在使用tab_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                />
     </LinearLayout>
</TabHost>


对于每个标签,我都在tabControllerView的onCreate中执行此操作:

spec = tabHost.newTabSpec("home").setIndicator("Home",
res.getDrawable(R.drawable.ic_tab_home)).setContent(intent);
    tabHost.addTab(spec);

最佳答案

您应该可以使用以下方法做到这一点:

        for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++){
            tabHost.getTabWidget().getChildAt(i).setPadding(0,0,0,0);
        }

10-07 13:00
查看更多