2012-07-12 66 views
0

我爲每個標籤設置了一個圖片,其結果與預期的一樣,但在某些設備(平板電腦或某些智能手機型號)上圖片看起來更大,文字更大。如何解決它?謝謝。安卓縮放標籤圖片

活動,

 StateListDrawable selector = new StateListDrawable(); 

     selector.addState(new int[] { android.R.attr.state_selected }, dSel); 

     icon.setImageDrawable(selector); 

佈局,

<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"> 

     <RelativeLayout  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 


     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_below="@+id/mainLayout"> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="0dip" 
       android:layout_weight="1" 
       android:scrollbars="none" 
       android:isScrollContainer="false"> 
      </FrameLayout> 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0" 
       /> 

     </LinearLayout>   

    </RelativeLayout> 

enter image description hereenter image description here

+0

有在您的各種繪製的文件夾特定的分辨率的圖像。 – Swayam 2012-07-12 09:18:16

+0

ummm不!我應該爲每個密度生成不同的分辨率,不是嗎?如果是的話,你能告訴我每個密度的圖像大小優化嗎? – Jaume 2012-07-12 09:24:11

+0

嗯,如果你在Eclipse中創建一個新的項目,你會發現圖標默認添加到可繪製的文件夾中。我建議你只使用這些尺寸。 – Swayam 2012-07-12 09:41:56

回答