I've been researching this question for a while and haven't found any good answers yet.
I understand how to use <declare-styleable>
; I understand that use of the AttributeSet methods (e.g., getAttributeValue()) don't resolve references or drill down into <style>
s; etc.
I think that Winitzki's answer to Difference between declare-styleable and style is exactly on the mark. Using a combination of obtainStyledAttributes and AttributeSet methods will get you most of what you might need.
What I can't figure out is why several different mechanisms are necessary to handle obtaining attributes.
My two (very related) questions are:
- Couldn't a single method be provided which returns all top-level attributes, drills down into
<style>
elements as necessary and resolves references? - Why can't
<attr>
s defined directly within<resource>
be included in<style>
elements (and a method provided to access them)? (This another way of asking what<declare-styleable>
provides.)
Thank you for any help!
Barry