【问题标题】:android styles.xml no resource found that matches the given name of: attrandroid styles.xml 找不到与给定名称匹配的资源:attr
【发布时间】:2015-09-30 19:28:18
【问题描述】:

我下载了这个项目来继续工作,它有很多错误。这是一个警报应用程序。由于错误,它也不会创建 R 文件。我已经看到了一个有效的构建,但由于这些错误,我没有可以编译的代码。我认为这是一个依赖问题,但我似乎无法弄清楚。清单文件 minSdk=14 和 TargetSdk = 19 则属性为 target: android-19。任何帮助表示赞赏。谢谢。

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

<!--

基础应用主题,取决于 API 级别。此主题已替换 在较新的设备上由来自 res/values-vXX/styles.xml 的 AppBaseTheme 提供。

-->

<style name="PreferencesTheme">
    <item name="android:background">#000000</item>
</style>

<style name="AppBaseTheme" parent="android:Theme.Light">
    <!--

更新的 API 级别中可用的主题自定义可以进入 res/values-vXX/styles.xml,而自定义相关 向后兼容可以放在这里。

    -->
</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:windowNoTitle">true</item>
    <item name="android:listSelector">@color/appBgColor</item>
    <item name="android:scrollbarThumbVertical">@drawable/rounded_vertical_scroll_track</item>
    <item name="android:scrollbarThumbHorizontal">@drawable/rounded_vertical_scroll_track</item>
    <item name="android:scrollbarSize">5dp</item>
    <item name="android:scrollbarStyle">insideOverlay</item>
    <item name="switchStyle">@style/switch_dark</item>
</style>

<style name="switch_dark">
    <item name="track">@drawable/switch_track_holo_dark</item>
    <item name="thumb">@drawable/switch_inner_holo_dark</item>
    <item name="textOn">@string/textOn</item>
    <item name="textOff">@string/textOff</item>
    <item name="thumbTextPadding">12dip</item>
    <item name="switchMinWidth">96dip</item>
    <item name="switchPadding">16dip</item>
    <item name="switchTextAppearance">@style/TextAppearance</item>
</style>

<style name="TextAppearance">
    <item name="textColor">@color/whiteColor</item>
    <item name="textColorHighlight">@color/whiteColor</item>
    <item name="textColorHint">@color/whiteColor</item>
    <item name="textColorLink">@color/whiteColor</item>
    <item name="textSize">16sp</item>
</style>

<!-- For Normal Text Size -->
<style name="normalTextSize" parent="@android:style/TextAppearance">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@color/whiteColor</item>
    <item name="android:textStyle">normal</item>
</style>

<!-- For Normal Text Size  With Bold -->
<style name="normalTextSizeWithBold" parent="@android:style/TextAppearance">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@color/whiteColor</item>
    <item name="android:textStyle">bold</item>
</style>

<!-- For Medium Text Size -->
<style name="mediumTextSize" parent="@android:style/TextAppearance">
    <item name="android:textSize">16sp</item>
    <item name="android:textColor">@color/whiteColor</item>
    <item name="android:textStyle">normal</item>
</style>

<!-- For Medium Text Size With Bold -->
<style name="mediumTextSizeWidthBold" parent="@android:style/TextAppearance">
    <item name="android:textSize">16sp</item>
    <item name="android:textColor">@color/whiteColor</item>
    <item name="android:textStyle">bold</item>
</style>

<!-- For Large Text Size -->
<style name="largeTextSize" parent="@android:style/TextAppearance">
    <item name="android:textSize">18sp</item>
    <item name="android:textColor">@color/whiteColor</item>
    <item name="android:textStyle">normal</item>
</style>

<!-- For Large Text Size With Bold -->
<style name="largeTextSizeWithBold" parent="@android:style/TextAppearance">
    <item name="android:textSize">18sp</item>
    <item name="android:textColor">@color/whiteColor</item>
    <item name="android:textStyle">bold</item>
</style>

<!-- For Custom Dialog -->

<style name="DialogAnimation">
    <item name="android:windowEnterAnimation">@anim/slide_up_dialog</item>
    <item name="android:windowExitAnimation">@anim/slide_out_dialog</item>
</style>

<!-- Animation for dialog box -->
<style name="DialogSlideAnim" parent="@android:style/Theme.Dialog">
    <item name="android:windowAnimationStyle">@style/DialogAnimation</item>
</style>

<style name="MyHolo" parent="@android:style/TextAppearance.Widget.TextView">
    <item name="android:editTextColor">#ffffff</item>
    <item name="android:textSize">100sp</item>
</style>

<style name="MyPreferencesTheme">
    <item name="android:windowBackground">@color/appBgColor</item>
    <item name="android:background">@color/appBgColor</item>
</style>

以下是错误:

C:\res\values\styles.xml 错误:(38, 22) 找不到与给定名称匹配的资源:attr 'switchStyle'。

错误:(53, 22) 找不到与给定名称匹配的资源:attr 'textColor'。

错误:(54, 22) 找不到与给定名称匹配的资源:attr 'textColorHighlight'。

错误:(55, 22) 找不到与给定名称匹配的资源:attr 'textColorHint'。 错误:(56, 22) 找不到与给定名称匹配的资源:attr 'textColorLink'。

错误:(57, 22) 找不到与给定名称匹配的资源:attr 'textSize'。

错误:(47, 22) 找不到与给定名称匹配的资源:attr 'switchMinWidth'。

错误:(48, 22) 找不到与给定名称匹配的资源:attr 'switchPadding'。

错误:(49, 22) 找不到与给定名称匹配的资源:attr 'switchTextAppearance'。

错误:(45, 22) 找不到与给定名称匹配的资源:attr 'textOff'。

错误:(44, 22) 找不到与给定名称匹配的资源:attr 'textOn'。

错误:(43, 22) 找不到与给定名称匹配的资源:attr 'thumb'。

错误:(46, 22) 找不到与给定名称匹配的资源:attr 'thumbTextPadding'。

错误:(34, 88) 找不到与给定名称匹配的资源:attr 'track'。

【问题讨论】:

    标签: android android-layout android-studio android-styles


    【解决方案1】:

    资源名称应为

    <item name="android:textColor">...</item>
    

    您错过了所有有问题资源的android: 部分

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题,但缺少不同的资源。 就我而言,我缺少 AppCompat 支持库之一所需的 SDK。

      检查您的构建配置并检查您是否安装了它们所引用的每个 SDK。

      这是因为,如果他们可以在构建期间使用较低的 API,他们使用的资源来自与您使用的库版本相同的 SDK。 例如,如果您使用 com.android.support:appcompat-v7:21.0.0 并且您计划在 Kitkat (19) 上运行您的应用程序来构建它,您将需要 Lollipop SDK。

      【讨论】:

      • 好的,我会检查一下,看看它是否有效。感谢回复
      • 仍然无法正常工作。我下载了所有 Lollipop sdk。
      • 你能发布你的 build.gradle 文件吗?或者至少是依赖部分。
      • dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile project(':Android Projects:SwitchCompatLibrary-master:SwitchCompatLibrary') compile project(':Android Projects:New folder') compile project(':eclipse:sdk:extras:google:google_play_services:libproject:google-play-services_lib') } android { compileSdkVersion 19 buildToolsVersion "23.0.0 rc3" compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 }
      • 有人有什么想法吗?
      猜你喜欢
      • 1970-01-01
      • 2015-05-19
      • 2017-10-13
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多