Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2030298
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: 嵌入式

2011-07-11 16:58:25

  1. 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
  2. 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
  3. Style Inherits
    1st way: use parent attribute.
    2nd way: use name attribute with '.' seperated, such as


  4. 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"
        />

  5. xxx
阅读(766) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~