我試圖使用色彩資源時發生lint錯誤。根據文件,以下內容應該是有效的。色彩資源中的錯誤
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="actionbar_title"></color>
</resources>
但是這給出了「屬性缺少Android命名空間前綴」。修訂到
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color android:name="actionbar_title"></color>
</resources>
清除錯誤,但在佈局文件中的以下定義
<TextView android:id="@+id/title"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/actionbar_title" />
給出了錯誤「錯誤:錯誤:沒有資源發現在給定的名稱與價值相匹配(在‘文字顏色’ 「@顏色/ actionbar_title」)
任何和所有幫助將受到讚賞
編輯:。 如由類型a1pha指出,上面沒指定一種顏色 - 我從測試版本複製。然而
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color android:name="actionbar_title">#ffffff</color>
</resources>
給lint警告
Unexpected text found in layout file: "#ffffff"
但顏色資源仍然沒有在佈局xml文件的認可。
那麼用名稱替換android:name呢? – kvh