【问题标题】:Android: Sherlock Tabs and ActionBar customizationAndroid:Sherlock Tabs 和 ActionBar 自定义
【发布时间】:2012-11-16 05:51:03
【问题描述】:

我需要一些关于操作栏和标签视图自定义的帮助。我使用 Sherlock ActionBar lib 并尝试将自定义选项卡/操作栏样式与 Theme.Sherlock 作为父项绑定到我的活动。但是它不起作用,没有错误,但没有任何改变。我做错了什么?

这是我的风格:(至少改变背景颜色):

<style name="AppBaseTheme" parent="Theme.Sherlock">
    <!--
        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="AppTheme" parent="AppBaseTheme">

    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabBarStyle">@style/MyActionBarTabBar</item>
    <item name="actionBarTabBarStyle">@style/MyActionBarTabBar</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTab</item>
    <item name="actionBarTabStyle">@style/MyActionBarTab</item>
</style>

<style name="MyActionBar" parent="Widget.Sherlock.ActionBar">
    <item name="android:background">@android:color/white</item>
</style>

<style name="MyActionBarTabBar" parent="Widget.Sherlock.ActionBar.TabBar">
    <item name="android:background">@android:color/black</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">match_parent</item>
</style>

<style name="MyActionBarTab" parent="Widget.Sherlock.ActionBar.TabView">
    <item name="android:background">@android:color/white</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
</style>

那是我的清单:

<application
    android:icon="@drawable/ic_launcher"
    android:logo="@drawable/abs__ic_go"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".FragmentTabsPager"
        android:label="@string/app_name"
        android:theme="@style/AppTHeme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我尝试分别使用 CUstomTabs 和 Theme.Styled(for ActionBar) 样式,但没有结果。

【问题讨论】:

    标签: android actionbarsherlock


    【解决方案1】:
    <style name="Widget.Sherlock.ActionBar.TabView" parent="Widget.Sherlock.ActionBar.TabView">
    

    您不应该为要扩展的父样式使用相同的名称。 android应该如何知道选择哪一个?

    一个有效的名称是包含您的主题名称以供识别:

    <style name="AppTheme.ActionBar.TabView" parent="Widget.Sherlock.ActionBar.TabView">
    

    【讨论】:

    • Thats the good note I have corrected it but its 仍然无法正常工作。
    • 能否请您也更新问题中的样式。只看实物
    • 您仍在为您的 CustomTabs 样式中的选项卡使用错误的样式。
    • 伙计们,请帮我解决这个问题。我完全不明白如何自定义样式,我已经尝试了很多不同的方法来做到这一点。也许,有人还有什么解决办法吗? By Sherlock 网站主题化非常容易,但在我的情况下不起作用。
    猜你喜欢
    • 2012-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多