2017-01-29 1 views
0

탭 위젯 레이아웃 화면의 표시 색상을 변경하려면 어떻게해야합니까? 현재는 흰색입니다. 나는 그것을 푸른 색으로 바꾸고 싶다.탭 위젯의 배경색

<?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

+0

[Android 탭 호스트 변경 텍스트 색상 스타일] (http://stackoverflow.com/questions/22533061/android-tabhost-change-text-color-style)의 가능한 중복 –

답변

0

에서 https://stackoverflow.com/a/38835247/4758255@will-molter 답 :

이 실제로 XML 테마를 사용하여 수행 할 수 있습니다. TabWidget은 선택한 탭에 android:textColorPrimary을 사용하고 선택하지 않은 탭에는 android:textColorSecondary을 사용합니다. 레이아웃에서

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

: styles.xml에서

:

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

참고 android:themeTabWidget에 직접적으로 안된다는 따라서, 당신은 텍스트 색이 같은 변화를 달성 할 수 자체가 아니라 TabHost 또는 이와 유사한 것을 포함합니다.

관련 문제