- Docs
- Applying Styles and Themes
http://developer.android.com/guide/topics/ui/themes.html - System Styles
http://developer.android.com/reference/android/R.style.html
- System Themes
http://developer.android.com/reference/android/R.styleable.html#Theme - Style Resources
http://developer.android.com/guide/topics/resources/style-resource.html - Referencing style attributes
http://developer.android.com/guide/topics/resources/accessing-resources.html#ReferencesToThemeAttributes
- xxx
- Summary
- What is style
A style is a set of one or more formatting attributes that you can apply as a unit to individual elements
in your layout(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.
For example, you could define a style that specifies a certain text size and color, then
apply it to only specific View elements.
- What is theme
A theme is a set of one or more formatting attributes that you can apply as a unit to all activities in
an application, or just a single activity, rather than an individual View.
For example, you could define a theme that sets specific colors for
the window frame and the panel background, and sets text sizes and colors for menus. This theme can then be
applied to specific activities or the entire application.
- xxx
- Style Inherits
1st way: use parent attribute.
2nd way: use name attribute with '.' seperated, such as
- Referencing style attributes
A style attribute resource allows you to reference the value
of an attribute defined in the currently-applied theme.
To reference a style attribute, the name syntax is
?[:][/]
Sample:
id="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:text="@string/hello_world" />
Here, the android:textColor attribute specifies the name of a style attribute in the current theme. Android now uses the value applied to the android:textColorSecondary style attribute as the value for android:textColor in this widget. Because the system resource tool knows that an attribute resource is expected in this context, you do not need to explicitly state the type (which would be ?android:attr/textColorSecondary)—you can exclude the attr type.
Another sample:
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
android:secondaryProgress="75" />
style="?android:attr/listSeparatorTextViewStyle"
android:text="@string/listSeparatorTextViewStyle"
android:layout_marginTop="5dip"
/>
- xxx
阅读(794) | 评论(0) | 转发(0) |