Let's start with an example
<attr name="spinnerDropDownItemStyle" format="reference" />
How do I take this apart and understand it?
I watch the Android themes & styles demystified - Google I/O 2016 talk multiple times and I still don't understand how this reference thing works.
Keywords: Mobile Android Attribute. 1. declare-style leable defines some attributes, writes some identical attributes together, defines a name, or can be directly defined. In the following two ways, just use declare-style leable to organize similar attributes together.
reference
format is used when the attribute refers to another resource ID. For example:
<!-- Declaration -->
<attr name="mydrawale" format="reference" />
<!-- Usage -->
app:mydrawable="@drawable/shape1"
So, resources like @layout/...
, @color/...
, @style/...
are of type reference
. However attribute formats like color
, boolean
, etc need also color literals (e.g. 0x00FF00
) and boolean literals (e.g. true
) respectively.
In your case, spinnerDropDownItemStyle
is an attribute that gets a resource like @style/...
which by itself is a pointer to a resource entry of type style.
By the way, you can set the format to multiple types using |
. For example for the following attribute both @color/mycolor
and 0x00FF00
are acceptable.
<attr name="mycolor" format="reference|color" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With