GeekHub - Android

Report 2 Downloads 41 Views
GeekHub - Android Season 3 (2013/2014) | Stage 2

Styles and Themes

Holo Light

Holo Dark

Holo Light with dark action bar

Styles and Themes Styles in Android share a similar philosophy to cascading stylesheets in web design - they allow you to separate the design from the content. For example, by using a style, you can take this layout XML:

And turn it into this:

Defining Styles To create a set of styles, save an XML file in the res/values/ directory of your project. The name of the XML file is arbitrary, but it must use the .xml extension and be saved in the res/values/ folder. The root node of the XML file must be . <style name="CodeFont" parent="@android:style/TextAppearance.Medium" > match_parent wrap_content #00FF00 monospace

Inheritance Inheriting from platform styles: <style name="GreenText" parent="@android:style/TextAppearance" > #00FF00

Inheriting from styles that you've defined yourself: <style name="CodeFont.Red" > #FF0000

<style name="CodeFont.Red.Big" > 30sp

Applying Styles and Themes to the UI There are two ways to set a style: ● To an individual View, by adding the style attribute to a View element in the XML for your layout. ● Or, to an entire Activity or application, by adding the android:theme attribute to the or element in the Android manifest.

Apply a theme to an Activity or application



<style name="CustomTheme" parent="android:Theme.Light" > @color/custom_theme_color @color/custom_theme_color



Android Asset Studio

Using Platform Styles and Themes R.style R.attr Android Styles (styles.xml) Android Themes (themes.xml)

Home Studying 1. Themes http://developer.android.com/design/style/themes.html 2. Styles and Themes http://developer.android.com/guide/topics/ui/themes.html 3. Resource Types http://developer.android.com/guide/topics/resources/availableresources.html 4. Android Asset Studio http://android-ui-utils.googlecode.com/hg/assetstudio/dist/index.html

Hometask 1. RSS Reader 2. Посмотреть слайды и видео: https://plus.google. com/+RomanNurik/posts/a6An6Y8Au3i 3. Применить полученные знания и навыки к своему приложению.