android
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
android [2022/09/03 17:50] – skipidar | android [2022/09/03 22:42] (current) – skipidar | ||
---|---|---|---|
Line 1335: | Line 1335: | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== Style ==== | ||
+ | |||
+ | === Styles, attributes === | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | |||
+ | === TextAppearance === | ||
+ | The text size in android is controlled by " | ||
+ | |||
+ | |||
+ | Material Design provides 13 type “styles” that are applied to all the text in your app. Each of these have a design term (eg. “Body 1”) along with a corresponding type attribute that can be overridden in your app theme (eg. textAppearanceBody1). There are default “baseline” values (text size, letter spacing, capitalization, | ||
+ | |||
+ | https:// | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | |||
+ | == Usage in your view == | ||
+ | |||
+ | At the end, | ||
+ | to express which size the text in your custom view should have | ||
+ | instead of influencing " | ||
+ | which will lead to difficulties with consistancy across app and consistancy with android native textSizes | ||
+ | |||
+ | you should set " | ||
+ | |||
+ | and the value should be one of androids own textAppearance **attributes**: | ||
+ | * textAppearanceHeadline1 | ||
+ | * textAppearanceHeadline2 | ||
+ | * textAppearanceHeadline3 | ||
+ | * textAppearanceHeadline4 | ||
+ | * textAppearanceBody1 | ||
+ | * textAppearanceBody2 | ||
+ | |||
+ | The same attributes are used by android too, so your view will be consistant with android natives | ||
+ | |||
+ | In your someAppPartLayout.xml | ||
+ | < | ||
+ | <!-- My title in my app view --> | ||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | </ | ||
+ | |||
+ | |||
+ | == Changing the value of attributes in AppTheme == | ||
+ | |||
+ | In your theme, maybe defined in your styles.xml | ||
+ | you can change single android attributes. | ||
+ | |||
+ | In my theme, which is defined in this style - overriding the single attributes " | ||
+ | referencing MY styles, which can interfere and override the default values for textAppearance. | ||
+ | |||
+ | **Remark: | ||
+ | Those textAppearance* attributes are also used in android native views, | ||
+ | like buttons | ||
+ | see https:// | ||
+ | So overriding those in a theme - changes the behavior also for Android native elements | ||
+ | |||
+ | THose attributes are not just strings, but are introduced as typed attributes in attrs.xml | ||
+ | with format=" | ||
+ | format=" | ||
+ | In the value-style element - the items a la android: | ||
+ | |||
+ | USAGE of attributes | ||
+ | The attribute can be USED in views, by refering to the attribute in the view | ||
+ | e.g. | ||
+ | < | ||
+ | |||
+ | In your styles.xml pointing textAppearanceHeadline1 attribute of type " | ||
+ | to my own style. | ||
+ | |||
+ | The style inherits from androids own style but I still can override some values in my inherited style. | ||
+ | |||
+ | < | ||
+ | <!-- Base application theme. --> | ||
+ | <style name=" | ||
+ | <!-- Customize your theme here. --> | ||
+ | <item name=" | ||
+ | <item name=" | ||
+ | <item name=" | ||
+ | |||
+ | |||
+ | <item name=" | ||
+ | @style/ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | == Introducing own styles, to refer from overridden attributes textAppearance* == | ||
+ | |||
+ | THe value of an overridden attribute **textAppearance*** is a style | ||
+ | |||
+ | |||
+ | in your styles.xml | ||
+ | parallel to the AppTheme - introduce styles, to refer from attributes. | ||
+ | < | ||
+ | |||
+ | <!-- here I can change attributes of the STYLES. | ||
+ | by Inheriting from " | ||
+ | but get the possibility to override them here | ||
+ | --> | ||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | |||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | |||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | |||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | |||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | |||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | |||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | |||
+ | <style name=" | ||
+ | <item name=" | ||
+ | </ | ||
+ | </ | ||
android.1662227418.txt.gz · Last modified: by skipidar