【问题标题】:Error:(25, 28) No resource found that matches the given name (at 'theme' with value '@style/AppTheme.NoActionBar')错误:(25, 28) 找不到与给定名称匹配的资源(在“主题”处,值为“@style/AppTheme.NoActionBar”)
【发布时间】:2018-05-29 01:37:29
【问题描述】:

有人可以解释一下 android studio 上的这个错误吗?

错误:(25, 28) 没有找到与给定名称匹配的资源(在 '主题',值为'@style/AppTheme.NoActionBar')。错误:(25, 28) 否 找到与给定名称匹配的资源(在具有值的“主题”处 '@style/AppTheme.NoActionBar')。

这是我的manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="foo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="25" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.SET_WALLPAPER" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true" >

        <!-- all the activities goes here -->
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

这是我的styles.xml 文件:

<resources>

    <style name="FreeWallTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBarTheme</item>

    </style>

    <style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@color/action_bar</item>
        <item name="android:titleTextStyle">@style/TitleTextStyle</item>
    </style>

    <style name="TitleTextStyle" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
        <item name="android:textColor">@color/action_bar_title</item>
    </style>

</resources>

提前致谢。

【问题讨论】:

    标签: android xml


    【解决方案1】:

    在现有代码中进行此更改

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
    
            android:supportsRtl="true" >
    
            <!-- all the activities goes here -->
            <activity
                android:name=".MainActivity"
                android:label="@string/app_name"
              android:theme="@style/AppTheme"
                >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    

    并添加样式

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/btn_background_green</item>
            <item name="colorAccent">@color/colorAccent</item>
        </style>
    

    【讨论】:

    • 只需在 style.xml 文件中添加 AppTheme 样式并替换为您的代码
    猜你喜欢
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2015-02-10
    • 2014-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多