In conclusion, do not forget
1) style is similar to CSS and used to define the attributes of view and other UI elements, such as layout_width. It can be referenced by @ style/name in layout XML.
2) If you want to add custom attributes to a style, you can define them in ATTR. An ATTR includes the name and format attributes, which can be referenced by @ ATTR/name in the style.
You can also define an attribute set in ATTR and define it with the declare-styleable tag. This attribute set is used in the view constructor.
Public View (context, attributeset attrs, int defstyle );
View, you can know the attributes in defstyle In the constructor.
The reference of an attribute set is different from that of a single attribute. It is referenced by R. styleable. Name.
3) theme is generally for activity and takes effect globally. Generally, style is specified in theme, which is generally completed by an attribute defined in ATTR.
For example, define the autocomplettextviewstyle attribute in ATTR and specify
<Item name = "autocompletetextviewstyle"> @ Android: style/widget. autocompletetextview </item>
In this way, you can use R. ATTR. autocompletetextviewstyle in the view constructor to obtain the style specified in theme.
In public view (context, attributeset attrs, int defstyle );
In, defstyle can be either a style: R. style. Name or R. ATTR. name. For the latter, you must specify the attribute value in theme.