1

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:

  1. Couldn't a single method be provided which returns all top-level attributes, drills down into <style> elements as necessary and resolves references?
  2. 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

Community
  • 1
  • 1
Barry Holroyd
  • 1,005
  • 1
  • 11
  • 20
  • 1) describes Context.obtainStyledAttributes() and 2) entirely misses the point of passing an array of relevant attributes into obtainStyledAttributes(). – alanv Oct 16 '14 at 00:13
  • Interesting question although I fear you are slightly confused about how styles work. – dcow Oct 16 '14 at 00:37

0 Answers0