风格被忽略,Lollipop的一切都是灰色的

时间:2014-11-16 16:55:09

标签: android android-studio

我正在尝试更改应用程序的样式,但所有内容都是灰色的。有什么问题?

我正在使用android studio。这个项目最初是在eclipse上进行的。我不是在Android Studio上使用Lollipop构建它

<application
        android:name=".MainApplication"
        tools:replace="android:icon,android:theme"
        android:label="@string/app_name"
        android:logo="@drawable/ic_logo"
        android:theme="@style/Theme.Materialred" >

styles_materialred.xml:

<resources>

    <style name="Theme.Materialred" parent="@style/Theme.AppCompat.Light">
        <item name="actionBarItemBackground">@drawable/selectable_background_materialred</item>
        <item name="popupMenuStyle">@style/PopupMenu.Materialred</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Materialred</item>
        <item name="actionBarTabStyle">@style/ActionBarTabStyle.Materialred</item>
        <item name="actionDropDownStyle">@style/DropDownNav.Materialred</item>
        <item name="actionBarStyle">@style/ActionBar.Solid.Materialred</item>
        <item name="actionModeBackground">@drawable/cab_background_top_materialred</item>
        <item name="actionModeSplitBackground">@drawable/cab_background_bottom_materialred</item>
        <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Materialred</item>


    </style>

    <style name="ActionBar.Solid.Materialred" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="background">@drawable/ab_solid_materialred</item>
        <item name="backgroundStacked">@drawable/ab_stacked_solid_materialred</item>
        <item name="backgroundSplit">@drawable/ab_bottom_solid_materialred</item>
        <item name="progressBarStyle">@style/ProgressBar.Materialred</item>
    </style>

    <style name="ActionBar.Transparent.Materialred" parent="@style/Widget.AppCompat.Light.ActionBar">
        <item name="background">@drawable/ab_transparent_materialred</item>
        <item name="progressBarStyle">@style/ProgressBar.Materialred</item>
    </style>

    <style name="PopupMenu.Materialred" parent="@style/Widget.AppCompat.Light.PopupMenu">   
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_materialred</item>   
    </style>

    <style name="DropDownListView.Materialred" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
        <item name="android:listSelector">@drawable/selectable_background_materialred</item>
    </style>

    <style name="ActionBarTabStyle.Materialred" parent="@style/Widget.AppCompat.Light.ActionBar.TabView">
        <item name="android:background">@drawable/tab_indicator_ab_materialred</item>
    </style>

    <style name="DropDownNav.Materialred" parent="@style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
        <item name="android:background">@drawable/spinner_background_ab_materialred</item>
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_materialred</item>
        <item name="android:dropDownSelector">@drawable/selectable_background_materialred</item>
    </style>

    <style name="ProgressBar.Materialred" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
        <item name="android:progressDrawable">@drawable/progress_horizontal_materialred</item>
    </style>

    <style name="ActionButton.CloseMode.Materialred" parent="@style/Widget.AppCompat.Light.ActionButton.CloseMode">
        <item name="android:background">@drawable/btn_cab_done_materialred</item>
    </style>

    <!-- this style is only referenced in a Light.DarkActionBar based theme -->
    <style name="Theme.Materialred.Widget" parent="@style/Theme.AppCompat">
        <item name="popupMenuStyle">@style/PopupMenu.Materialred</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Materialred</item>
    </style>

3 个答案:

答案 0 :(得分:1)

在动作栏主题中以这种方式设置颜色。

<item name="colorPrimary">@color/primaryDef</item>

阅读Chris Banes https://chris.banes.me/2014/10/17/appcompat-v21/#migrationfromprevioussetup

这篇有趣的文章

答案 1 :(得分:1)

我遇到了这个问题,只是注意到Lollipop有一个单独的styles.xml文件。它最初是由默认文件隐藏的,但单击箭头会显示它。编辑这个按预期工作。

tree showing res->values->styles.xml->styles.xml

答案 2 :(得分:0)

你必须使用它:

   <style name="AppThemeRandom" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->

    <!-- The primary branding color for the app. By default, this is the color applied to the
     action bar background. -->
    <item name="colorPrimary">@color/md_indigo_500</item>
    <!-- Dark variant of the primary branding color. By default, this is the color applied to
     the status bar (via statusBarColor) and navigation bar (via navigationBarColor). -->
    <item name="colorPrimaryDark">@color/md_indigo_700</item>
    <!-- Bright complement to the primary branding color. By default, this is the color applied
     to framework controls (via colorControlActivated). -->
    <item name="colorAccent">@color/md_pink_A200</item>
    <!-- The color applied to framework controls in their normal state. -->
    <item name="colorControlNormal">@color/md_amber_500</item>
    <!-- The color applied to framework controls in their activated (ex. checked) state. -->
    <item name="colorControlActivated">@color/md_green_500</item>
    <!-- The color applied to framework control highlights (ex. ripples, list selectors). -->
    <item name="colorControlHighlight">@color/md_teal_500</item>
    <!-- The color applied to framework buttons in their normal state. -->
    <item name="colorButtonNormal">@color/md_red_500</item>
    <!-- The color applied to framework switch thumbs in their normal state. -->
    <item name="colorSwitchThumbNormal">@color/md_black_1000_50</item>
    <!-- Inactive track color(75% transparency) -->
    <item name="android:colorForeground">@color/md_black_1000_75</item>
</style>

显然,选择你的颜色,检查状态栏,工具栏,复选框等小工具等所有颜色是一个随机主题。

相关问题