2014-10-20 31 views
7

我想自定義材質設計主題,在這個環節上建議: android dev的是Android 5.0 - 的IntelliJ搖籃:無法解析符號:@color:material_blue_500

但是當我下面的代碼添加到我的V21 /風格文件Intellij說它無法解析這些符號。

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light"> 
     <!-- customize the color palette --> 
     <item name="colorPrimary">@color/material_blue_500</item> 
     <item name="colorPrimaryDark">@color/material_blue_700</item> 
     <item name="colorAccent">@color/material_green_A200</item> 
    </style> 

</resources> 

我環顧四周,看是否有任何特定的設置需要在顏色方面完成,但沒有出現。我在Gradle上使用支持lib v7的API 21。

回答

14

@color/material_blue_500和其他不是android庫中的資源。

您必須自己定義res/values/colors.xml中的顏色資源。

例如<color name="material_blue_500">#5677fc</color>

然後你可以使用它作爲<item name="colorPrimary">@color/material_blue_500</item>

+3

對不起,我應該做更多的研究..顏色材料的意見在這裏給出:http://www.google.com/design/spec/style/color.html# – nathandrake 2014-10-20 08:12:35

6

Android文檔對此非常模糊,導致混淆。要獲取預定義的顏色,請將color_material.xml複製到本地res/values dir。該文件是Android-L期間的保存版本。在官方版本,它坐落在您的本地目錄:

... SDK /平臺/ Android的21 /數據/ RES /價值/ colors_material.xml

已經下調,以消除那些顏色定義。