I'm a using a view flow component into my project, which allows the dev to override some attributes, like that :
<org.taptwo.android.widget.TitleFlowIndicator
...
app:footerTriangleHeight="0dip"
... />
I am reusing this component into several layouts, and I would like to put the properties into a style.
But when I'm doing this, the parser says Error: No resource found that matches the given name: attr 'app:footerTriangleHeight'
, even if I add the namespace in the styles file.
Is there a way to do that in android ?
Thanks.
Android Application
If you are not using Android Libraries, then here is what you can do:
Example:
In attrs.xml:
In styles.xml:
Android Library
If custom attribute comes from Android Library, you can still use described approach. It theoretically should work, because Android Library's namespace is the same as application's (from
aapt
tool perspective during the build). But I haven't test this myself.If you're specifying namespace, it will show error. As far as I know, styles do not support xml namespaces. So this will fail:
In styles.xml:
Parser automatically defaults to current app's
AndroidManifest
namespace, though you can not specify this namespace explicitly.You can define the style in terms of your namespace, i've used it myself
i.e