[英]Android Tab icon image full size
我有一個帶有 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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.