【问题标题】:Android:Custom Theme:styles:Error retrieving parent for item: No resource found that matches the given nameAndroid:自定义主题:样式:检索项目的父项时出错:找不到与给定名称匹配的资源
【发布时间】:2015-12-25 01:31:30
【问题描述】:

我自定义了Theme,但出现错误

检索项目的父项时出错:找不到与给定名称匹配的资源

styles.xml 文件中。我的错在哪里?

我的主题.xml:

    <!-- Custom Theme Design By Hossein -->
<style name="Theme.CustomThemeHossein">
    <item name="android:windowNoTitle">true</item>
     <item name="colorBackground">@android:color/background_light</item>
       <item name="windowBackground">@android:drawable/bghos</item>
    <item name="colorBackground">@android:color/background_light</item>
    <item name="colorForeground">@color/bright_foreground_light</item>
    <item name="colorForegroundInverse">@android:color/bright_foreground_light_inverse</item>

    <item name="textColorPrimary">@android:color/primary_text_light</item>
    <item name="textColorSecondary">@android:color/secondary_text_light</item>
    <item name="textColorTertiary">@android:color/tertiary_text_light</item>
    <item name="textColorPrimaryInverse">@android:color/primary_text_dark</item>
    <item name="textColorSecondaryInverse">@android:color/secondary_text_dark</item>
    <item name="textColorTertiaryInverse">@android:color/tertiary_text_dark</item>
    <item name="textColorPrimaryDisableOnly">@android:color/primary_text_light_disable_only</item>
    <item name="textColorPrimaryInverseDisableOnly">@android:color/primary_text_dark_disable_only</item>
    <item name="textColorPrimaryNoDisable">@android:color/primary_text_light_nodisable</item>
    <item name="textColorSecondaryNoDisable">@android:color/secondary_text_light_nodisable</item>
    <item name="textColorPrimaryInverseNoDisable">@android:color/primary_text_dark_nodisable</item>
    <item name="textColorSecondaryInverseNoDisable">@android:color/secondary_text_dark_nodisable</item>
    <item name="textColorHint">@android:color/hint_foreground_light</item>
    <item name="textColorHintInverse">@android:color/hint_foreground_dark</item>        
    <item name="textColorHighlight">@android:color/highlighted_text_light</item>
    <item name="textColorHighlightInverse">@android:color/highlighted_text_dark</item>
    <item name="textColorLink">@android:color/link_text_light</item>
    <item name="textColorLinkInverse">@android:color/link_text_dark</item>

    <item name="editTextColor">@android:color/primary_text_light</item>
    <item name="listChoiceBackgroundIndicator">@android:drawable/list_selector_background</item>

    <item name="activatedBackgroundIndicator">@android:drawable/activated_background_light</item>
    <item name="quickContactBadgeOverlay">@android:drawable/quickcontact_badge_overlay_light</item>

    <item name="popupWindowStyle">@android:style/Widget.PopupWindow</item>

    <item name="textCheckMark">@android:drawable/indicator_check_mark_light</item>
    <item name="textCheckMarkInverse">@android:drawable/indicator_check_mark_dark</item>

    <item name="gestureOverlayViewStyle">@android:style/Widget.GestureOverlayView.White</item>
    <item name="expandableListViewStyle">@android:style/Widget.ExpandableListView.White</item>
    <item name="listViewStyle">@android:style/Widget.ListView.White</item>
    <item name="listDivider">@drawable/divider_horizontal_bright</item>
    <item name="listSeparatorTextViewStyle">@android:style/Widget.TextView.ListSeparator.White</item>

    <item name="progressBarStyle">@android:style/Widget.ProgressBar.Inverse</item>
    <item name="progressBarStyleSmall">@android:style/Widget.ProgressBar.Small.Inverse</item>
    <item name="progressBarStyleLarge">@android:style/Widget.ProgressBar.Large.Inverse</item>
    <item name="progressBarStyleInverse">@android:style/Widget.ProgressBar</item>
    <item name="progressBarStyleSmallInverse">@android:style/Widget.ProgressBar.Small</item>
    <item name="progressBarStyleLargeInverse">@android:style/Widget.ProgressBar.Large</item>
    <item name="actionModeCutDrawable">@android:drawable/ic_menu_cut_holo_light</item>
    <item name="actionModeCopyDrawable">@android:drawable/ic_menu_copy_holo_light</item>
    <item name="actionModePasteDrawable">@android:drawable/ic_menu_paste_holo_light</item>
    <item name="actionModeSelectAllDrawable">@android:drawable/ic_menu_selectall_holo_light</item>
    <item name="actionModeShareDrawable">@android:drawable/ic_menu_share_holo_light</item>
    <item name="actionModeFindDrawable">@android:drawable/ic_menu_find_holo_light</item>
    <item name="actionModeWebSearchDrawable">@android:drawable/ic_menu_search_holo_light</item>
    <item name="actionModeBackground">@android:drawable/cab_background_top_holo_light</item>
    <item name="actionModeSplitBackground">@android:drawable/cab_background_bottom_holo_light</item>

    <!-- SearchView attributes -->
    <item name="searchDropdownBackground">@android:drawable/search_dropdown_light</item>
    <item name="searchViewTextField">@drawable/textfield_searchview_holo_light</item>
    <item name="searchViewTextFieldRight">@drawable/textfield_searchview_right_holo_light</item>
    <item name="searchViewCloseIcon">@android:drawable/ic_clear_holo_light</item>
    <item name="searchViewSearchIcon">@android:drawable/ic_search_api_holo_light</item>
    <item name="searchViewGoIcon">@android:drawable/ic_go_search_api_holo_light</item>
    <item name="searchViewVoiceIcon">@android:drawable/ic_voice_search_api_holo_light</item>
    <item name="searchViewEditQuery">@android:drawable/ic_commit_search_api_holo_light</item>

    <item name="detailsElementBackground">@android:drawable/panel_bg_holo_light</item>

    <item name="mediaRouteButtonStyle">@android:style/Widget.DeviceDefault.Light.MediaRouteButton</item>
    <item name="findOnPageNextDrawable">@android:drawable/ic_find_next_holo_light</item>
    <item name="findOnPagePreviousDrawable">@android:drawable/ic_find_previous_holo_light</item>
</style>

我的样式.xml:

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.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="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

    <style name="CustomThemeHossein" parent="android:Theme.CustomThemeHossein">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

我的 AndroidManifest.xml:

   <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/CustomThemeHossein" >

错误:

[2015-12-18 14:19:54 - WifiTrafficMonitor] E:\E\All-Project\Android\WifiTrafficMonitor\res\values\styles.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.CustomThemeHossein'.

如何解决?

【问题讨论】:

    标签: android android-theme android-styles


    【解决方案1】:

    您必须将Theme.CustomThemeHossein 更改为:

    <style name="CustomThemeHossein">
    

    themes.xml 中并使用以下方式调用此主题:

    <style name="ThemeHossein" parent="@style/CustomThemeHossein">
    

    因为它是&lt;style&gt; 而不是&lt;theme&gt;

    【讨论】:

    • 我试了一下,没用,导致这个错误Description Resource Path Location Type error: Error retrieving parent for item: No resource found that matches the given name 'Theme.CustomThemeHossein'. styles.xml /WifiTrafficMonitor/res/values line 20 Android AAPT Problem
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-27
    • 2014-06-04
    • 2017-02-10
    • 2017-06-27
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多