Android Styles & Themes (next) - Theme

2010-07-10  来源:本站原创  分类:Mobile  人气:200 

On a space Android Styles & Themes (1) - Style Style introduced the magic charm, the following effects continue to experience the Theme. The same as Style, Theme <style> elements still inside it clear that reference is in the same way. The difference is that through the Android Manifest and <activity> <application> defined theme elements to add to the whole program or an Activity, but the theme is not used in a View in a separate.

An example of the definition of Theme

<? Xml version = "1.0" encoding = "UTF-8"?>
<style name="NewTheme" parent="android:Theme.Black">
<item name="android:windowNoTitle"> true </ item>
<item name="android:textSize"> 14sp </ item>
<item name="android:textColor"> # FFFF0000 </ item>
</ Style>
</ Resources>

The definition of the above resources, I believe we see at, needs to be emphasized here is: some resources used in the definition of @ symbol and? Symbols to refer to resources. , The role of these two symbols are explained as follows:

  • @ Shows that our application resources are defined through the front (or the previous project, the framework or Android).
  • ? That the value of our resources referenced in the current definition of the subject were too.

These skills can only be used among XML resources

Theme in the program using the method

protected void onCreate (Bundle savedInstanceState) (
super.onCreate (savedInstanceState);
setTheme (;
setContentView (R.layout.main);
It should be noted that the theme of resources for reference, resource ID is not a file name (theme.xml), but the resource name (NewTheme). After running the interface shown below:

Application of Theme in AndroidManifest.xml

  • In order to use among all current Activity Theme, you can open AndroidManifest.xml file, edit <application> label, let contain android: theme attribute value is the name of a theme, such as: <application android: theme = "@ style / NewTheme ">.
  • If you only want one program which Activity has the Theme, you can modify <activity> label. Android provides several built-in resources, there are several Theme you can switch without having to write your own. For example you can use the dialog box to make your Activity Theme looks like a dialog box. Defined in the manifest, for example: <activity android:theme="@android:style/Theme.Dialog">
  • If you prefer a Theme, but to do some minor changes, just to add to this Theme for the parent. Android SDK provides us with a lot of ready-made Theme, some are listed below:
    Android Styles & Themes (next) - Theme

    For example: we modify the Theme.Dialog Theme, inheritance Theme.Dialog to generate a new Theme. <style parent="@android:style/Theme.Dialog">
    Inherited Theme.Dialog, we can adjust according to our requirements Theme. We can modify the definition in the Theme.Dialog in the value of each item element, and then we use in the Android Manifest file NewDialogTheme not Theme.Dialog.

Summary Description

Relatively simple example above, also found in the use of many problems, such as Android SDK a theme.xml defined as follows:
<? Xml version = "1.0" encoding = "utf-8"?>
<style name="CustomTheme">
<item name="android:windowNoTitle"> true </ item>
<item name="windowFrame"> @ drawable / screen_frame </ item>
<item name="windowBackground"> @ drawable / screen_background_white </ item>
<item name="panelForegroundColor"> # FF000000 </ item>
<item name="panelBackgroundColor"> # FFFFFFFF </ item>
<item name="panelTextColor">? panelForegroundColor </ item>
<item name="panelTextSize"> 14 </ item>
<item name="menuItemTextColor">? panelTextColor </ item>
<item name="menuItemTextSize">? panelTextSize </ item>
</ Style>
</ Resources>

This example looks, it was found a few places not meet the specifications:

  1. item name without the prefix attribute some of Android, Android SDK that it seems inconsistent with the norms defined, standardized Xiangjie read AndroidManifest.xml file structure description ;
  2. <item name="panelTextSize"> 14 </ item>, the value of the lack of units, should be 14sp;

Reference to the program this theme, we found the following error: Error: no resource found that matches the given name: panelForegroundColor, this error is astonishing. Android SDK provides examples of procedures previously found some minor problems, such as: XML file in less symbol. "Theme Wendang because of the definition of which properties in the end there, Google did not provide documentation shows that this error does not know how changes. In the next google online, many people have found this problem, currently no one specific solution is given, we will continue to in-depth research Theme, have the same problem in the follow-up length in the solution to the problem .

  • Android Styles & Themes (next) - Theme 2010-07-10

    On a space Android Styles & Themes (1) - Style Style introduced the magic charm, the following effects continue to experience the Theme. The same as Style, Theme <style> elements still inside it clear that reference is in the same way. The diffe

  • Android Styles & Themes - Theme 2011-05-26 An example of the definition of Theme <?xml version="1.0″ encoding="UTF-8″?> <resources> <style name="NewTheme" parent="android:Theme.Black"> <item name="android:windo

  • Android Styles & Themes 2010-04-17

    Theme is a pattern set can be used to override the appearance of Android components. Android's theme is used by the web design CSS (Cascading Style Sheets, Cascading Style Sheets) inspired, cascading style sheet will be displayed on the screen the co

  • Android Styles & Themes (on) - Style 2010-07-10

    Android SDK to see it earlier on Applying Styles and Themes in the introduction and instructions, and today finally had time to experience down. And CSS in the same web, Android can also be defined for the interface overall, common Style. Styles and

  • Android Styles and Themes 2015-03-04

    A style is a collection of properties that specify the look and format for a 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

  • Android中Style和Theme的使用总结 2013-02-05

    越来越多互联网企业都在Android平台上部署其客户端,为了提升用户体验,这些客户端都做得布局合理而且美观.......Android的Style设计就是提升用户体验的关键之一.Android上的Style分为了两个方面: Theme是针对窗体级别的,改变窗体样式: Style是针对窗体元素级别的,改变指定控件或者Layout的样式. Android系统的themes.xml和style.xml(位于/base/core/res/res/values/)包含了很多系统定义好的style,建议在里

  • android Resource Collection (rpm) 2011-01-01

    Android development tools and resources useful selection of Android Quick Tip: Using the Quick Contact Badge shortcut Android SDK: Introduction to Gestures gestures http:

  • Applying Styles and Themes - Application Style and Theme - Android Chinese translation of official documents 2010-12-31

    Original link: Original title: Applying Styles and Themes Original version: Android 2.2 r1 - 05 Aug 2010 8:29 Chinese translation: Jack Yu ( [email protected] ) Use only non-profit, reproduced

  • Android style and theme development and application of the difference between 2010-11-03

    Transfer from ( ) Android xml style and theme of document preparation, related to the program interface is beautiful and one of the factors. Better application of styles and themes can

  • Android Introduction and Theme sixteenth chapter of Style 2011-01-13

    More and more Internet companies are in the deployment of its Android platform clients, in order to enhance the user experience, these clients have done a reasonable layout and good looking ....... Android's Style Design is one of the keys to enhance

  • Introduction to the sixteenth chapter of Style Android and Theme (rpm) 2011-01-14

    More and more Internet companies are in the deployment of its Android platform clients, in order to enhance the user experience, these clients have done a reasonable layout and good looking ....... Android's Style Design is one of the keys to enhance

  • Android入门之Style与Theme用法实例解析 2014-04-24

    这篇文章主要介绍了Android入门之Style与Theme用法,非常实用的功能,需要的朋友可以参考下 就目前的互联网发展来看,已经有越来越多互联网企业都在Android平台上部署其客户端,并且为了提升用户体验,这些客户端都做得布局合理而且美观.本文所要介绍的Android的Style设计就是提升用户体验的关键之一.Android上的Style分为了两个方面: 1.Theme是针对窗体级别的,改变窗体样式: 2.Style是针对窗体元素级别的,改变指定控件或者Layout的样式. Android

  • AutoCompleteTextView white theme Theme_Light problem set 2010-12-24

    AutoCompleteTextView set in white down the options when the subject is white no content Solution 1. use an extended theme in your manifest: ... <application android:theme="@style/Theme.Light.NoTitleBar.Workaround" ... > ... 2. create the n

  • android 开源项目分类 2014-08-13

    目前包括: Android开源项目第一篇--个性化控件(View)篇 包括ListView.ActionBar.Menu.ViewPager.Gallery.GridView.ImageView.ProgressBar.TextView.ScrollView.TimeView.TipView.FlipView.ColorPickView.GraphView.UI Style.其他 Android开源项目第二篇--工具库篇 包括依赖注入.图片缓存.网络相关.数据库ORM工具包.Android公共库

  • Android开源项目分类汇总 2015-03-05

    目录(?)[-] Android开源项目分类汇总 第一部分 个性化控件View 一ListView 二ActionBar 三Menu 四ViewPager Gallery 五GridView 六ImageView 七ProgressBar 八TextView 九ScrollView 十TimeView 十一TipView 十二FlipView 十三ColorPickView 十四GraphView 十五UI Style 十六其他 第二部分 工具库 一依赖注入DI 二图片缓存 三网络相关 四数据库

  • Computer wallpaper theme of sharing fine finishing 09-01 to share updates! 2010-09-01

    Red Cliff Zhao Zilong Themes Theme Type: XP Themes / Theme Size: 5.6 MB Red Cliff Zhao Zilong Themes: The theme from the theme of family love Chibi game tailor made. "Red Cliff" With Perfect self-developed engine, the game screen absolutely fabu

  • appfuse theme of the realization principle 2010-10-28

    appfuse css which can provide multiple sets of dynamic change, to change the look and feel of the goal. Are placed in each topic theme web / styles / directory, a folder for each theme. Folder name is the name of the theme. Configure the default valu

  • Win7 install themes in their own file locations 2011-05-05

    In WIN7 in some cases do not want to install too many themes, but the subject needs to be installed over the background image. That position is stored in these pictures C:\Users\blackbamboo\AppData\Local\Microsoft\Windows\Themes One blackbamboo compu

  • Android中删除Preference详解 2015-01-08

    这篇文章主要介绍了Android中删除Preference详解,很多时候删除Preference总会失败,本文着重分析删除失败的原因,需要的朋友可以参考下 Android的设置界面实现比较简单,有时甚至只需要使用一个简单的xml文件即可.声明简单,但是如何从PreferenceScreen或者PreferenceCategory中删除一个Preference会简单么.为什么有些人写的就无法删除成功呢?本文将从Android源码实现来分析一下. 声明文件 <?xml version="1.0

  • android 适配器的简易笔记 2014-12-14

    (一).使用ArrayAdapter做适配器: 常用在:Spinner ①设置数据源 ②使用ArrayAdapter做适配器,使用方法同Spinner ③ 给ListView对象设置适配器 String[] arrayData = { "网络设置", "wifi设置", "蓝牙设置", "网络设置2", "wifi设置2","蓝牙设置2", "网络设置3", &quo