0

How can I change the display color of tab widget layout screen? Currently it's white. I want to change it to blue.

<?xml version="1.0" encoding="utf-8"?>
<TabHost android:id="@android:id/tabhost"  android:layout_width="fill_parent" android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto">
    <LinearLayout android:orientation="vertical" android:id="@id/mainLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ff2356bf" >
        <FrameLayout  android:layout_width="0.0dip" android:layout_height="0.0dip" android:layout_weight="0.0" />
        <TabWidget android:orientation="horizontal" android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.0" />
        <android.support.v4.view.ViewPager android:id="@id/pager" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0" />
        <LinearLayout android:layout_gravity="center" android:orientation="vertical" android:id="@id/BannerLayout" android:paddingBottom="2.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
            <com.google.android.gms.ads.AdView android:layout_gravity="center_horizontal" android:id="@id/adView" android:layout_width="fill_parent" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="@string/banner" />
        </LinearLayout>
    </LinearLayout>
</TabHost>

enter image description here

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Asim khan
  • 39
  • 6

1 Answers1

0

From https://stackoverflow.com/a/38835247/4758255 @will-molter answer:

This can actually be done using XML themes. The TabWidget uses android:textColorPrimary for the selected tab and android:textColorSecondary for the unselected ones. Thus, you can achieve a text color change like this:

In styles.xml:

<style name="TabWidgetTheme" parent="AppTheme">
    <item name="android:textColorPrimary">@color/your_primary_color</item>
    <item name="android:textColorSecondary">@color/your_secondary_color</item>
</style>

In your layout:

<TabHost
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:theme="@style/TabWidgetTheme"/>

Note that the android:theme should not be directly in the TabWidget itself, but rather the containing TabHost or similar.

Community
  • 1
  • 1
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96