Reputation: 21
I feel like I'm missing something very simple. I've changed the background color on my other apps in the past but this is the first app I've made that implements Tabs. All Im trying to do is make the background of the app content, which has a bunch of buttons, black. Normally I would just change the linear layout or something black but Ive changed so many things to black using #000000 but it doesnt work anymore. Im sure tabhost has something to do with it but I need a kick in the right direction. Heres my 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" />
The xml goes on with my other tabs and finishes the xml with the standard finishers, but nothing seems to turn the background black. Its default is white and wont change. Please advise! Thank you.
Upvotes: 1
Views: 4273
Reputation: 1500
In default android tab bar color will be in Grey, you can easily change the color of the tab bar.
Use the below line of code to change the color of Tab`
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.RED); or tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#4E4E9C"));
For further Reference.
http://www.technotalkative.com/android-change-tab-bar-background-color/
http://www.androidpeople.com/android-tabhost-tutorial-%E2%80%93-part-2
`
Upvotes: 6