1

非常に単純なものが欠けているように感じます。過去に他のアプリで背景色を変更したことはありますが、タブを実装するアプリを作成したのはこれが初めてです。私がやろうとしているのは、たくさんのボタンがあるアプリ コンテンツの背景を黒くすることだけです。通常、線形レイアウトまたは何か黒を変更するだけですが、#000000 を使用して非常に多くのものを黒に変更しましたが、もう機能しません。タブホストが何か関係があると確信していますが、正しい方向へのキックが必要です。ここに私のlayout.xmlがあります:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >


<TabHost
    android:id="@+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" >
        </TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#000000" >

            <ScrollView
                android:id="@+id/scrollView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#000000" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:background="#000000" >

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

                        <Button
                            android:id="@+id/button1"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:background="@drawable/buttonbg"
                            android:gravity="center_horizontal"
                            android:padding="10dp"
                            android:shadowColor="#f5f5f5"
                            android:shadowDx="1"
                            android:shadowDy="1"
                            android:shadowRadius="1"
                            android:textColor="#DAA520"
                            android:textSize="12pt" />

                        <Button
                            android:id="@+id/button2"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:background="@drawable/buttonbg"
                            android:gravity="center_horizontal"
                            android:padding="10dp"
                            android:shadowColor="#f5f5f5"
                            android:shadowDx="1"
                            android:shadowDy="1"
                            android:shadowRadius="1"
                            android:textColor="#DAA520"
                            android:textSize="12pt" />

                        <Button
                            android:id="@+id/button3"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:background="@drawable/buttonbg"
                            android:gravity="center_horizontal"
                            android:padding="10dp"
                            android:shadowColor="#f5f5f5"
                            android:shadowDx="1"
                            android:shadowDy="1"
                            android:shadowRadius="1"
                            android:textColor="#DAA520"
                            android:textSize="12pt" />

                        <Button
                            android:id="@+id/button4"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:background="@drawable/buttonbg"
                            android:gravity="center_horizontal"
                            android:padding="10dp"
                            android:shadowColor="#f5f5f5"
                            android:shadowDx="1"
                            android:shadowDy="1"
                            android:shadowRadius="1"
                            android:textColor="#DAA520"
                            android:textSize="12pt" />

xml は私の他のタブに続き、標準のフィニッシャーで xml を終了しますが、何も背景を黒くしないようです。デフォルトは白で、変更されません。お知らせ下さい!ありがとうございました。

4

1 に答える 1

6

デフォルトのAndroidタブバーの色は灰色になります。タブバーの色は簡単に変更できます。

以下のコード行を使用して、Tab`の色を変更します

tabHost.getTabWidget()。getChildAt(i).setBackgroundColor(Color.RED); またはtabHost.getTabWidget()。getChildAt(0).setBackgroundColor(Color.parseColor( "#4E4E9C"));

詳細については。

http://www.technotalkative.com/android-change-tab-bar-background-color/

http://www.androidpeople.com/android-tabhost-tutorial-%E2%80%93-part-2

`

于 2012-07-23T07:22:57.050 に答える