我使用此操作栏样式生成器为我的应用程序创建了一个主题。不影响标签的主题
http://jgilfelt.github.io/android-actionbarstylegenerator/
我已经设置了标签颜色以橙色,但它并不影响我的布局选项卡。
我的布局看起来如下。
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@android:id/tabhost" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@+id/tabFrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
下面是我在我的样式文件和清单文件中的其他内容。
清单文件
android:theme="@style/Theme.Silence"
styles_silence.xml
<style name="Theme.Silence" parent="android:Theme.Holo.Light">
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Silence</item>
...
</style>
...
<style name="ActionBarTabStyle.Silence" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_silence</item>
</style>
tab_indicator_ab_silence.xml
(这是由我先前链接的程序生成)<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@android:color/transparent" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_silence" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_silence" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_silence" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_silence" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_silence" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_silence" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_silence" />
</selector>
我查了this document,在我看来,一切都好。什么可能是错的?
谢谢!这也适用,但有点奇怪。你提到了ActionBar的方式。你的意思是[这个](http://developer.android.com/guide/topics/ui/actionbar.html#Tabs)?如果我没有完全误解,它可以与支持库一起使用API 10。我对么? – MikkoP
@MikkoP我已经讲过'ActionBar',提到样式不匹配。 'ActionBar'对tabs视图和控制器有不同的实现,它不会**使用'TabHost'(以及一个'TabWidget'),所以样式也会不同。你发布的链接指的是ActionBar的选项卡(你确实可以实现较低的API版本,但这不重要,因为你正在处理**内容视图**中的一个“TabHost”部分)该应用程序)。 – Luksprog
你是什么意思?“但是这并不重要,因为你正在处理应用程序的内容视图部分中的TabHost”?我想我是否用这个替换了我的TabWidget。 – MikkoP