【问题标题】:Android: Styling the Tab Bar for multiple versionsAndroid:为多个版本设置标签栏样式
【发布时间】:2014-03-06 02:06:20
【问题描述】:

我正在尝试使用 xml 来设置标签的样式。我正在关注本指南:https://developer.android.com/training/basics/actionbar/styling.html

我的应用跨越 2.3.3 到 4.3 版本。我会提交我的代码,但老实说我没有任何代码,因为我不知道从哪里开始。该教程似乎对我根本不起作用。我要做的就是更改选项卡的背景颜色和文本颜色。 Eclipse 生成了一个结构,该结构在文件夹valuesvalues-v11values-v14 中包含styles.xml 文件。这是我的基本样式.xml。老实说,我只是不确定哪些标签在哪些文件中。

更新

我已导入 v4 和 v7 支持库。另外,现在我的 styles.xml 看起来像这样

<resources xmlns:android="http://schemas.android.com/apk/res/android">

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="TCMBaseTheme" parent="@style/Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="TCMTheme" parent="TCMBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="actionBarTabStyle">@style/TCMActionBarTabs</item>
</style>

<!-- ActionBar tabs styles -->
<style name="TCMActionBarTabs"
       parent="@style/Widget.AppCompat.ActionBar.TabView">
    <item name="android:background">@color/tcmblue</item>
    <!-- tab indicator -->


    <!-- Support library compatibility -->
    <item name="background">@color/tcmblue</item>
</style>

</resources>

我已将 TCMBaseTheme 设置为清单中的主题。现在没有错误,但是当我运行应用程序时,标签栏颜色没有变化。

【问题讨论】:

    标签: android android-theme android-tabs


    【解决方案1】:

    我认为你不见了:

    <item name="android:actionBarTabStyle">@style/TCMActionBarTabs</item>
    

    在TCMThemestyle.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-07
      • 2018-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-18
      • 2013-10-01
      • 1970-01-01
      相关资源
      最近更新 更多