質問

どうなるかはわからないかったのが期間自TabWidgetた白色のタブに見られる優しい人ばかりなんですよ。さんマインや背景色に私のプロジェクトです。次回をまとめましたのでよろしければここに戻しのグレーのタブにするようにしたアプリを使用してデフォルトの暗いテーマです。ってもアプリケーションを設定しテーマは、タブがグレーとなります。なすことができませんでしたその他のタブカラーです。誰にでもいるのか?

役に立ちましたか?

解決

をしていて問題によるバグを修正Android1.6の光をテーマにした(タブ表示テキストはホワイト)です。このオーバーライドのデフォルトのテーマとして

  1. 作成したカスタムテーマから継承されたデフォルトのテーマ:

styles.xml:

<style name="MyTheme" parent="@android:style/Theme.Light">
    <item name="android:tabWidgetStyle">@style/LightTabWidget</item>
</style>

<style name="LightTabWidget" parent="@android:style/Widget.TabWidget">
    <!-- set textColor to red, so you can verify that it applied. -->
    <item name="android:textColor">#f00</item>
</style>

そしてだけ適用することをテーマに自分を追加 android:theme="@style/MyTheme"<application /> 要素の AndroidManifest.xml.

他のヒント

チェック解答の鉱山: 背景タブウィジェットを無視するスケーリング

していますのでご覧ください、 android.graphics.drawable パッケージ

コードを設定することができた背景用タブのようになります:

tabHost.getTabWidget().getChildAt(0).setBackgroundResource(
            android.R.color.white);
public void onCreate(Bundle savedInstanceState)中に

           `tabHost = getTabHost();
            tabHost.setOnTabChangedListener(this);
    tabHost.setCurrentTab(0);
    setTabColor();`
リスナーよりも

公共ボイドonTabChanged(文字列tabId){         setTabColor();

最後に、あまりにも前景と背景の設定機能、:

public void setTabColor() {
    // set foreground color:
    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
        RelativeLayout rl = (RelativeLayout) tabHost.getTabWidget().getChildAt(i);
        ImageView imageView = (ImageView) rl.getChildAt(0);// change it if you want it
        TextView textView = (TextView) rl.getChildAt(1);//          
        textView.setTextColor(Color.parseColor("#FFFFFF"));
    }

    // set background color:
    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
        tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#010101")); // unselected
    }
    tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#121288")); // selected
}
onCreatedの

()

    tabHost.setCurrentTab(0);

// Set tabs text color to white:
TabWidget tabWidget = tabHost.getTabWidget();
int whiteColor = getResources().getColor(R.color.white);
int someOtherColor = getResources().getColor(R.color.someOtherColor);
for(int i = 0; i < tabWidget.getChildCount(); i++){
    View tabWidgetChild = tabWidget.getChildAt(i);
    if(tabWidgetChild instanceof TextView){
        ((TextView) tabWidgetChild).setTextColor(whiteColor);
    } else if(tabWidgetChild instanceof Button){
        ((Button) tabWidgetChild).setTextColor(whiteColor);
    } else if(tabWidgetChild instanceof ViewGroup){
        ViewGroup vg = (ViewGroup)tabWidgetChild;
        for(int y = 0; y < vg.getChildCount(); y++){
            View vgChild = vg.getChildAt(y);
            if(vgChild instanceof TextView){
                ((TextView) vgChild).setTextColor(whiteColor);
            }
        }
        vg.setBackgroundColor(someOtherColor);
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top