Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Theming In Android

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

Theming In Android

This deck was originally presented at JavaCloud 2019 and it is all about theming your Android app using Google's Material Design.
Topics Covered:
- Color
- Typography
- Themes
- Styles

Avatar for Pabi Moloi

Pabi Moloi

July 25, 2019
Tweet

More Decks by Pabi Moloi

Other Decks in Technology

Transcript

  1. • A theme is a unifying idea and theming is

    designing or bringing that idea to life to an object or space • Create a holistic look and feel
  2. Why is it important? • Create a memorable and meaningful

    experience • Create reusable set of attributes to apply to your entire app
  3. Consistency With regard to mobile apps, consistency is: • Visual

    Consistency • Functional Consistency • External Consistency -Smashing Magazine
  4. <!--?xml version="1.0" encoding="UTF-8"?--> <resources> <color name="primaryColor">#f9a825</color> <color name="primaryLightColor">#ffd95a</color> <color name="primaryDarkColor">#c17900</color>

    <color name="secondaryColor">#ffffff</color> <color name="secondaryLightColor">#ffffff</color> <color name="secondaryDarkColor">#25cccccc</color> <color name="primaryTextColor">#ffffff</color> <color name="secondaryTextColor">#000000</color> </resources>
  5. <!--?xml version="1.0" encoding="UTF-8"?--> <resources> <color name="primaryColor">#f9a825</color> <color name="primaryLightColor">#ffd95a</color> <color name="primaryDarkColor">#c17900</color>

    <color name="secondaryColor">#ffffff</color> <color name="secondaryLightColor">#ffffff</color> <color name="secondaryDarkColor">#25cccccc</color> <color name="primaryTextColor">#ffffff</color> <color name="secondaryTextColor">#000000</color> </resources>
  6. <!--?xml version="1.0" encoding="UTF-8"?--> <resources> <color name="red">#d32f2f</color> <color name="mustard">#F9A825</color> <color name="yellow">#ffd95a</color>

    <color name="dark_mustard">#c17900</color> <color name="white">#ffffff</color> <color name="light_grey">#25CCCCCC</color> <color name="black">#000000</color> </resources>
  7. <style name="..." parent="..."> <item name="colorPrimary">@color/mustard</item> <item name= "colorOnPrimary">@color/white</item> <item name="colorPrimaryVariant">@color/dark_mustard</item>

    <item name="colorAccent">@color/red</item> <item name="colorSecondary">@color/white</item> <item name="colorOnSecondary">@color/black</item> </style>
  8. Recap • Give colors names, which helps in the reduction

    of duplication. • “On” colours are usually used for iconography, text, and strokes
  9. Typography Attributes Headline : • textAppearanceHeadline1 • textAppearanceHeadline2 • textAppearanceHeadline3

    • textAppearanceHeadline4 • textAppearanceHeadline5 • textAppearanceHeadline6
  10. Recap • Typography is not just about choosing a typeface

    • Material Design type scale has a range of styles for you to use • Google Fonts is an awesome place to find open source fonts
  11. Recap • To customize a look of a view, create

    a style, and apply that style to it • Refer to documentation to see what attributes are available to style a particular view
  12. ...is a type of style that is applied to: •

    The entire application • Activity • View Hierarchy
  13. <style name="NoActionBarTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> <item name="colorPrimary">@color/mustard</item> <item name= "colorOnPrimary">@color/white</item> <item name="colorPrimaryVariant">@color/yellow</item>

    <item name="colorAccent">@color/red</item> <item name="colorSecondary">@color/white</item> <item name="colorOnSecondary">@color/black</item> <item name="android:windowBackground">@color/white</item> </style
  14. <style name="BlueGreenTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <item name="colorPrimary">@color/blue</item> <item name= "colorOnPrimary">@color/white</item> <item name="colorPrimaryVariant">@color/light_blue</item>

    <item name="colorAccent">@color/green</item> <item name="colorSecondary">@color/white</item> <item name="colorOnSecondary">@color/black</item> . . . </style>
  15. Recap • Avoid hardcoding values • Create a theme for

    styles that are consistent throughout the app
  16. • Uses dark grey as the primary surface color for

    components ◦ Helps in reducing eye strain • Elevated surfaces are illuminated ◦ The higher the elevation, the lighter the surface • “On” colours on a dark theme are white and black
  17. Dark Theme Benefits • Power usage reduction • Makes it

    easier to use your device in a low light environment • Improves visibility for users with low vision
  18. Recap • DayNight can be applied to both AppCompat and

    MaterialComponents • Do not hardcode values • Dark theme uses grey instead of black • Keep accessibility in mind
  19. Android’s Style Hierarchy 1. Applying character- or paragraph-level styling via

    text spans to textview-derived classes 2. Applying attributes programmatically 3. Applying individual attributes directly to a View 4. Applying a style to a View
  20. Android’s Style Hierarchy 5. Default styling 6. Applying a theme

    to a collection of Views, an activity, or your entire app 7. Applying certain View-specific styling, such as setting a textappearance on a textview
  21. Resources • Material Design ◦ https://material.io/ • Android Developer Guide

    User Interface ◦ https://developer.android.com/guide/topics/ui • Smashing Magazine ◦ https://www.smashingmagazine.com/2018/02/comprehensive-guide-to-mobile -app-design/