themes & styles - android mubasher
TRANSCRIPT
![Page 1: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/1.jpg)
Android Themes &
StylesBy Mohammed Ersan
![Page 2: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/2.jpg)
Who Am I?Mohammed Ersan
Senior Android Developer
MTT Dublin
Github @MoshDev
![Page 3: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/3.jpg)
Themes & Styles
![Page 4: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/4.jpg)
Themes & Styles
Style vs Theme
Style Basics
Inheritance
Attributes
View Constructors
Material
Theme Shared Styles
In-Layout Theme
ContextThemeWrapper
Selectors & Drawables
Hints & Tools
![Page 5: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/5.jpg)
Style
A style is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout.
Theme
A theme is a style applied to an entire Activity or application, rather than an individual View. When a style is applied as a theme, every View in the Activity or application will apply each style property that it supports.
Style vs Theme
Source: https://developer.android.com/guide/topics/ui/themes.html
![Page 6: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/6.jpg)
Style Theme
Style vs Theme
![Page 7: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/7.jpg)
Xml file
res/values
Root node <resources>
<style>
Name is required
<item>
Parent is Optional
AAPT (Android Asset Packaging Tool)
Style Basics
Source: https://developer.android.com/guide/topics/ui/themes.htmlhttp://elinux.org/Android_aapt
![Page 8: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/8.jpg)
Parent
<style name="MyButtonStyle" parent="@style/Widget.AppCompat.Button">
Period (dot)
only works for styles defined by your own resources
<style name="style_vs_theme_body_text.sample">
Period + Parent
<style name="style_vs_theme_body_text.sample" parent="Widget.AppCompat.Button">
Period + Parent =””
<style name="style_vs_theme_body_text.sample" parent="">
Inheritance
![Page 9: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/9.jpg)
● Format
○ Enum (only integers)
○ Boolean (true|false)
○ Color
○ Dimension
○ Flag (only integers)
○ Float
○ Fraction (only percentage %)
○ Integer
○ Reference (@)
○ String
● Pipe operator | OR
● Within attribute enums
Attributes (Properties)● Declare-styleable
○ R.styleable.<name>
○ R.styleable.<name>_<attribute>
![Page 10: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/10.jpg)
View(Context)
View(Context, AttributeSet) **
View(Context, AttributeSet, defStyleAttr)
View(Context, AttributeSet, defStyleAttr, defStyleRes) (Api 21)
View Constructors
![Page 11: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/11.jpg)
1. colorPrimary2. colorPrimaryDark3. colorControlNormal4. colorControlActivated5. colorButtonNormal6. textColorPrimary7. textColorSecondary8. textColorPrimaryDisableOnly9. textColorTertiary10.textColorHint11.windowBackground
Material
![Page 12: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/12.jpg)
toolbarStyle
buttonStyle
textViewStyle
checkboxStyle
…
Theme Default StylesTo change default view style
Check the <View> source code
Search Platform/AppCompat theme source code
Override the attribute value in your theme
![Page 13: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/13.jpg)
In-Layout Themeandroid:theme
Individual views
ViewGroup Inheritance
ContextThemeWrapperTextView1 --> ...InLayoutThemeActivity@7d3740eTextView2 --> android.view.ContextThemeWrapper@5c46c40TextView3 --> android.view.ContextThemeWrapper@b0afcbeTextView4 --> android.view.ContextThemeWrapper@b0afcbe
![Page 14: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/14.jpg)
ContextThemeWrapper
![Page 15: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/15.jpg)
Selectors & Drawables
![Page 16: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/16.jpg)
Hints & ToolsAlpha colors
![Page 17: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/17.jpg)
Hints & ToolsExtract Style
![Page 18: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/18.jpg)
ConclusionThemes are very powerful tool in Android, start using them correctly since the beginning of development and it will end well.
![Page 19: Themes & Styles - Android Mubasher](https://reader035.vdocuments.mx/reader035/viewer/2022062822/588340f11a28abbe6b8b4b63/html5/thumbnails/19.jpg)
Questions
つづく