What are the differences between R.styleable, R.style and R.attr? I found TextAppearance in all of these three classes.
R. attr is used to define attributes for custom views.
Filters. Capable of being styled. adjective. (computing) Capable of being formatted with styles. adjective.
R.style
has all styles android provided (including all Theme android provided). E.g., Theme.Translucent
, Widget.AbsListView
.
R.attr
has all attrs android provided (that could be set to view or window). E.g., layout_width
can be set to view, windowIsFloating
can be set to window.
R.styleable
has all attrs of a specific view or window that android provided AND can be defined in a style. E.g., FrameLayout_Layout_layout_gravity
: layout_gravity can be styled for FrameLayout, Window_windowIsFloating
: Flag indicating whether this is a floating window.
To answer your question, TextAppearance is a attribute (R.attr) AND it is declared styleable, attrs.xml:
<attr name="textAppearance" format="reference" />
<declare-styleable name="TextViewAppearance">
<!-- Base text color, typeface, size, and style. -->
<attr name="textAppearance" />
</declare-styleable>
TextAppearance is also a Theme/ Style (Theme is just a style), styles.xml:
<style name="TextAppearance">
<item name="android:textColor">?textColorPrimary</item>
<item name="android:textColorHighlight">?textColorHighlight</item>
<item name="android:textColorHint">?textColorHint</item>
<item name="android:textColorLink">?textColorLink</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
</style>
Just in case you don't understand what the "?" means, check: Question mark (?) in XML attributes for Android And in case you are puzzled by what is declare-styleable, check: Difference between declare-styleable and style
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