2016-10-07 19 views
-2

我正在尝试开发和android应用程序,而且我被这个错误困住了好几天。我知道有类似的问题通过阅读他们不幸没有帮助我。 这里是我的AndroidManifest.xml找不到与给定名称相匹配的资源(在'主题'中使用值'@ style/AppTheme')

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.kostas.android.waveradio" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="17" 
    android:targetSdkVersion="23" /> 

<application 
    android:name="com.android.tools.fd.runtime.BootstrapApplication" 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme" > 
    <activity android:name="com.kostas.android.waveradio.MainActivity" > 
     <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="MyMaterialTheme" parent="MyMaterialTheme.Base"> 

    </style> 

    <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <item name="windowNoTitle">true</item> 
     <item name="windowActionBar">false</item> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

    <style name="MyMaterialTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    <style name="MyMaterialTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

    </resources> 

非常感谢你提前。

+0

已更新我的回答,提供更多信息。请接受它是否解决了你的答案,或者它是否帮助你找到答案并且upvote(如果你愿意的话)。这会给你声誉,并且也会向我捐赠代表。 –

+0

似乎你不太了解Android样式的工作原理。 [这是一个详细的教程](http://www.androidhive.info/2015/04/android-getting-started-with-material-design/)! –

回答

1

您的styles.xml中没有任何样式,名称为“AppTheme”。

E.G:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- This means your Activity will be using the Light theme with no ActionBar --> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/primary</item> <!-- This is the primary color of your app, it is used for the ActionBar/Toolbar for example. --> 
    <item name="colorPrimaryDark">@color/primary_dark</item> <!-- Color of Status bar on API 21+ --> 
    <item name="colorAccent">@color/accent</item> <--This is the accent color, used for FloatingActionBar and other things like the EditText divider --> 
</style> 

现在,你可能想知道“什么是@color/primary”(否则你不知道什么是你目前得到的错误是)。

转到您的colors.xmlres>values>colors.xml),并定义primaryprimary_dark,并accent与你想要的颜色。 (我建议this site来为你做它,因为它挑选的好材料颜色):

<color name="primary"><!-- Your color --></color> 
<color name="primary_dark"><!-- Your color --></color> 
<color name="acent"><!-- Your color --></color> 

记得用您想要的颜色,以取代<!-- Your color -->(如#3367d6

下面是一张说明每个属性做什么。

image

+0

感谢您的回复。我使用了我在styles.xml中给出的代码,但是现在出现错误:“错误:(267,34)找不到与给定名称匹配的资源('colorAccent'值为'@ color/accent') “ –

+0

@KostasSt我会更新我的问题 –

+0

已更新的答案。 –

相关问题