2012-09-25 33 views
-1

enter image description here如何在TabWidget中製作自定義字體樣式?

我想改變我在我的android應用程序中創建的Tab中的Font。

這裏是我的xml文件:

<com.markupartist.android.widget.ActionBar 
    android:id="@+id/actionbar" 
    style="@style/ActionBar" /> 

<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" 
    android:background="@android:color/white" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="fill_vertical" 
     android:orientation="vertical" > 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@android:color/darker_gray" 
      android:orientation="horizontal" 
      android:paddingTop="0dp" 
      android:tabStripEnabled="true" /> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:padding="5dp" /> 
    </LinearLayout> 
</TabHost> 

,這裏是我的活動:

公共類Home_Activity擴展TabActivity {

private static final int DIALOG_REALLY_EXIT_ID = 0; 

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.home); 

    final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar); 
    actionBar.setTitle(getString(R.string.app_name)); 

    Intent intent = new Intent(Intent.ACTION_SEND); 
    intent.setType("text/plain"); 
    intent.putExtra(Intent.EXTRA_SUBJECT, "I've Been Using"); 
    intent.putExtra(Intent.EXTRA_TEXT, "BikeDSS Application by: Chocholuis"); 

    final Action shareAction = new IntentAction(this, Intent.createChooser(
      intent, "Share BikeDSS"), R.drawable.icon_share); 
    actionBar.addAction(shareAction); 

    Action searchAction = new IntentAction(this, new Intent(this, 
      search_activity.class), R.drawable.icon_search); 
    actionBar.addAction(searchAction); 

    Resources res = getResources(); // Resource object to get Drawables 
    TabHost tabHost = getTabHost(); // The activity TabHost 
    TabHost.TabSpec spec; // Reusable TabSpec for each tab 
    // Intent intent; // Reusable Intent for each tab 

    // Create an Intent to launch an Activity for the tab (to be reused) 
    intent = new Intent().setClass(this, Tab_Bike_Activity.class); 

    // Initialize a TabSpec for each tab and add it to the TabHost 
    spec = tabHost.newTabSpec("bike") 
      .setIndicator("Bike", res.getDrawable(R.drawable.sepeda)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    // Do the same for the other tabs 
    intent = new Intent().setClass(this, Tab_Brand_ListView_Activity.class); 
    spec = tabHost.newTabSpec("information") 
      .setIndicator("Information", res.getDrawable(R.drawable.info)) 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, 
      Tab_Shop_Repair_ListView_Activity.class); 
    spec = tabHost 
      .newTabSpec("repair") 
      .setIndicator("Shop and Bicycle Repair", 
        res.getDrawable(R.drawable.bengkel)).setContent(intent); 
    tabHost.addTab(spec); 

    tabHost.setCurrentTab(0); 

} 

是否可以改變字體?我真的需要幫助。 謝謝

+0

看看這個問題http://stackoverflow.com/questions/5788971/how-to-change-the-font-size-of-tabhost-in-android –

回答

相關問題