ThemeOverlay.AppCompat& android:colorBackground属性

时间:2015-06-05 08:19:29

标签: android android-support-library android-appcompat android-styles android-toolbar

我试图覆盖我的工具栏的背景颜色,我无法理解为什么通过覆盖android:background属性它起作用,而不是重写android:colorBackground它不起作用。 我查看了Appcompat的主题(V 22.2.0),我发现有android:colorBackground属性,并且没有android:background。 有人可以解释一下吗?

修改 第二个相关问题:我看到 Base.ThemeOverlay.AppCompat 没有父级。那么, ThemeOverlay.AppCompat.Dark.ActionBar 从哪里继承了它的android:background属性?

布局

<android.support.v7.widget.Toolbar 
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ToolBarStyle" />

<style name="ToolBarStyle" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:background">#2578bc</item>
    <!-- <item name="android:colorBackground">#2578bc</item> THIS DOESNT WORK -->
</style>

AppCompat的theme_base.xml

<style name="Base.ThemeOverlay.AppCompat.Dark">
    <item name="android:windowBackground">@color/background_material_dark</item>
    <item name="android:colorForeground">@color/bright_foreground_material_dark</item>
    <item name="android:colorForegroundInverse">@color/bright_foreground_material_light</item>
    <item name="android:colorBackground">@color/background_material_dark</item>
    <item name="android:colorBackgroundCacheHint">@color/abc_background_cache_hint_selector_material_dark</item>

    <item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
    <item name="android:textColorPrimaryInverse">@color/abc_primary_text_material_light</item>
    <item name="android:textColorPrimaryDisableOnly">@color/abc_primary_text_disable_only_material_dark</item>
    <item name="android:textColorSecondary">@color/abc_secondary_text_material_dark</item>
    <item name="android:textColorSecondaryInverse">@color/abc_secondary_text_material_light</item>
    <item name="android:textColorTertiary">@color/abc_secondary_text_material_dark</item>
    <item name="android:textColorTertiaryInverse">@color/abc_secondary_text_material_light</item>
    <item name="android:textColorHint">@color/hint_foreground_material_dark</item>
    <item name="android:textColorHintInverse">@color/hint_foreground_material_light</item>
    <item name="android:textColorHighlight">@color/highlighted_text_material_dark</item>
    <item name="android:textColorLink">@color/link_text_material_dark</item>

    <item name="colorControlNormal">?android:attr/textColorSecondary</item>
    <item name="colorControlHighlight">@color/ripple_material_dark</item>
    <item name="colorButtonNormal">@color/button_material_dark</item>
    <item name="colorSwitchThumbNormal">@color/switch_thumb_material_dark</item>

    <!-- Used by MediaRouter -->
    <item name="isLightTheme">false</item>
</style>

0 个答案:

没有答案