更改选项卡内容中的Android背景颜色

use*_*891 1 tabs android

我觉得我错过了很简单的事情.我过去在其他应用程序上更改了背景颜色,但这是我制作的第一个实现Tabs的应用程序.我试图做的就是制作app内容的背景,其中有一堆按钮,黑色.通常情况下,我只是改变线性布局或黑色,但我已经使用#000000改变了很多东西,但它不再起作用了.我确定tabhost与它有关,但我需要向正确的方向踢.继承我的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" />
Run Code Online (Sandbox Code Playgroud)

xml继续使用我的其他选项卡并使用标准终结器完成xml,但似乎没有任何东西将背景变为黑色.它的默认值是白色,不会改变.请指教!谢谢.

raj*_*ran 6

在默认的android标签栏颜色将为灰色,您可以轻松更改标签栏的颜色.

使用下面的代码行来更改Tab`的颜色

.tabHost.getTabWidget()getChildAt(ⅰ).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

`