2016-10-07 17 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

已更新的答案。 –

相關問題