Custom attrs parameter used in styles.xml
The XML namespace mechanism is used to namespace tags and attributes. When you define a style like this:
<?xml version="1.0" encoding="utf-8"?>
<resources
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.my.project">
<style name="my_style"> <item name="custom:tag">some_value</item> </style>
</resources>
you are trying to apply XML namespacing to an attribute value, which won't work. In this case, you should specify the package name directly, like this:
<style name="my_style"> <item name="com.my.project:tag">some_value</item> </style>
Now Android will be able to resolve where the attribute is defined.
The accepted solution did not work for me, but it shed some light upon the situation.
The custom attributes are resolved and can be referenced in a global project's package name, like "com.ltst.project". Even if you have multiple modules (with the same base package name) the resources would be resolved in a project's package name.
So for me it was enough to just omit any prefixes for custom attributes in a style.
Custom attribute:
<declare-styleable name="SampleView">
<attr name="sample_color" format="reference" />
</declare-styleable>
Style:
<style name="SampleStyle">
<item name="sample_color">@color/sample_color</item>
</style>