2011-08-10 68 views
1

我有一個簡單的tabController與4個選項卡,但我希望圖標圖像佔用整個選項卡。我還希望圖標圖像頂部的選項卡文本。我只需要一些提示就可以走向正確的方向。安卓標籤圖標圖像全尺寸

我無法發佈我的標籤看起來像(沒有足夠的聲望點)的圖像。但基本上,我需要騎在選項卡圖標周圍的所有填充。

我的圖標是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); 

回答

1

你應該能夠做到這一點與像這樣:

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