2011-11-14 4 views
0

私はAndroidプロジェクトに取り組んでいます。私のプロジェクトでは、私はタブレイアウトを使用しています。それはうまく動作しますが、すべてのタブの背景が黒であり、タブを選択するとそのタブの背景が明るい茶色に変わります。カスタムカラーを与えることは可能ですか?タブの背景を変更するには?

私の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:id="@+id/LinearLayout01" 
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" 

></TabWidget> 

<FrameLayout 
android:id="@android:id/tabcontent" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 

></FrameLayout> 


</LinearLayout> 



</TabHost> 

私のJavaコードは、あなたがスタイルを定義して使用する必要があります

Resources res = getResources(); 
    TabHost tb=getTabHost(); 
    Intent i; 
    TabHost.TabSpec spec; 




    spec = tb.newTabSpec("mee").setIndicator ("home").setContent(i); 



    tb.addTab(spec); 


    spec=tb.newTabSpec("contacts").setIndicator("search").setContent(i); 
    tb.addTab(spec); 

答えて

関連する問題