0
이 질문은 여러 번 질문되었지만 나에게 맞는 xml 스타일로만 명확한 해결책을 찾을 수 없습니다. 그래서 다른 예제에서는 액션 바의 탭을 다시 사용하므로 내 경우가 아닙니다. style.xml에서TabWidget의 배경색을 변경하는 방법 (xml에만 해당)
android:theme="@style/AppTheme"
:
가 actionbar_tab_indicator.xml에서<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>
<item name="actionBarTabStyle">@style/MyActionBarTabs</item>
</style>
<style name="MyActionBarTabs" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/actionbar_tab_indicator</item>
<item name="background">@drawable/actionbar_tab_indicator</item>
</style>
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- STATES WHEN BUTTON IS NOT PRESSED -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/red_spec" />
<item android:state_focused="false" android:state_selected="true"
android:state_pressed="false"
android:drawable="@color/red_spec" />
<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/red_spec" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="false"
android:drawable="@color/red_spec" />
<!-- STATES WHEN BUTTON IS PRESSED -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="true"
android:drawable="@color/red_spec" />
<item android:state_focused="false" android:state_selected="true"
android:state_pressed="true"
android:drawable="@color/red_spec" />
<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="true"
android:drawable="@color/red_spec" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="true"
android:drawable="@color/red_spec" />
</selector>
스타일의 조합을 사용하여 이상에서 작동하지 않습니다 매니페스트에서
모든. 아무것도 바뀌지 않습니다.는 글꼴 스타일을 변경하는 경우에만 작동하지만 배경하지 않습니다 아래 나는이 스타일을 사용하는 경우 : 이것은 TabHost에 따라 조각 레이아웃을 만들기 위해 사용하고 조각이
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
<item name="android:background">@color/red_overlay_spec</item>
</style>
<style name="CustomTabWidgetText" parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">25sp</item>
<item name="android:textStyle">bold</item>
</style>
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:background="@color/core_blue_bgr" >
<TabHost
android:id="@android: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"
android:layout_weight="0"
android:orientation="horizontal" />
<!-- tab host should have frameLayout with this ID
but is not use for content-->
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<!-- the real content is put here -->
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</TabHost>
</LinearLayout>