Declaring styleable attributes in Android

There's precious little documentation about the declare-styleable tag by which we can declare custom styles for components. I did find this list of valid values for the format attribute of the attr tag. While that's nice as far as it goes, it doesn't explain how to use some of those values. Browsing attr.xml (the Android source for the standard attributes), I discovered that you can do things like:



The format attribute can evidently be set to a combination of values. Presumably the format attribute helps the parser interpret an actual style value. Then I discovered this in attr.xml:



    
    
    
    




    
    
    

Both of these seem to declare a set of allowed values for the indicated style.

So I have two questions:

  1. What's the difference between a style attribute that can take on one of a set of enum values and one that can take on a set of flag values?
  2. Does anyone know of any better documentation for how declare-styleable works (other than reverse engineering the Android source code)?

77
задан Laurence Gonsalves 21 July 2017 в 17:54
поделиться