1

enter image description here對齊tabwidget中的字體

我自己設計了一個使用GPS和地圖的應用程序。我已經創建了用戶界面作爲選項卡。但我無法將字體保留在圖像下方。

代碼在我Mainactivity

TabSpec gpsspec = tabHost.newTabSpec("GPS"); 
gpsspec.setIndicator("GPS", getResources().getDrawable(R.drawable.gps)); 
Intent gpsIntent = new Intent(this, GpsActivity.class); 
gpsspec.setContent(gpsIntent); 
tabHost.addTab(gpsspec); 

XML文件在我的繪製文件夾選項卡

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <!-- When selected, use grey --> 
    <item android:drawable="@drawable/gps_icon" 
      android:state_selected="true" /> 
    <!-- When not selected, use white--> 
    <item android:drawable="@drawable/gps_icon" /> 
</selector> 

main.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:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

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

在調整字體請幫助。

回答

3

您需要在drawable-mdpi文件夾提供

  • 對小密度設備的圖標小尺寸drawable-ldpi文件夾中密度設備的圖標
  • 中等大小
  • 大尺寸的圖標在大密度裝置drawable-hdpi文件夾

Here是文檔指南的尺寸的drawable和d佈局。

如果它不能解決您的問題,您可以考慮提供您自己的自定義選項卡指示符,我已在my post here中使用它。