Reputation: 23
I'm getting lint errors attempting to use color resources. According to the documentation, the following should be valid.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="actionbar_title"></color>
</resources>
But this gives "Attribute is missing the Android namespace prefix". Amending to
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color android:name="actionbar_title"></color>
</resources>
clears the error but in a layout file the following definition
<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" />
gives the error "error: Error: No resource found that matches the given name (at 'textColor' with value '@color/actionbar_title').
Any and all help will be appreciated.
EDIT: As pointed out by type-a1pha, the above did not specify a color - I've copied from a test version. However
<?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>
gives the lint warning
Unexpected text found in layout file: "#ffffff"
but the color resource is still not recognised in the layout xml file.
Upvotes: 1
Views: 1355
Reputation: 2124
You should put your file under "values" folder instead of the "color" folder.
Upvotes: 0
Reputation:
<color name="actionbar_title"></color>
the color is empty i see.
<color name="actionbar_title">#000000</color>
Upvotes: 0
Reputation: 1893
You need to actually define the color:
<color name="white">#FFFFFF</color>
that is, give its hexadecimal code.
Upvotes: 2