Lecture 5: Styles and Themes Flashcards
What is the difference between styles and themes?
Style: XML objects designed to apply styling to a particular view
Theme: XML object designed to apply styling to the entire app or activity. Themes apply to all views within an app or activity
What type of file is the styles file and where is it stored?
XML
/res/values/styles.xml
How can you apply a style to a view?
Set the parents view’s style property with @filename/stylename
How can you apply a theme?
Once youve declared a style you can use it as a theme by modifying the app manifest and adding the android:theme property to the ‘application’ or ‘activity’ objects
What property is used to define which style a style object inherits from?
parent
How many style properties can a view have?
1
What is the work around for applying additional styling to a view?
Use a theme or inherit the style then modify it
Overlapping style properties in a child will ____ the inherited style properties of the parent object
override
What is the styling hierarchy?
- Applying character- or paragraph-level styling via text spans to TextView-derived classes
- Applying attributes programmatically
- Applying individual attributes directly to a View
- Applying a style to a View
- Default styling
- Applying a theme to a collection of Views, an activity, or your entire app
- Applying certain View-specific styling, such as setting a TextAppearance on a TextView
What property is used to style text and what does it style?
TextApperance
Styles font size, color, etc
What is the file used to store colors, what type of file is it, and where is it stored?
colors.xml
/res/values/
How do you reference colors defined in the colors.xml?
@colors/colorPrimary
What function can you use to programmatically set themes for activities?
setTheme() and recreate()