分类: android 2013-10-11 15:01 960人阅读 评论(0) 收藏 举报
android style和theme的使用。
style:样式,用来描述单独的view控件,改变其样式。
theme:主题,用来控制整个应用的主题,或者某个activity的主题。 style的使用:改变某控件的样式。
在style.xml中描述样式信息
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3. <style name="TextAttr">
  4. <item name="android:textSize">22sp</item>
  5. <item name="android:textColor">#0000CC</item>
  6. </style>
  7. </resources>
在控件(TextView,EditText,Layout)中使用控件来显示其样式。
<TextView
        style="@style/TextAttr"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="样式" />
Theme的使用,用来改变窗体的展示。
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3. <style name="TextAttr">
  4. <item name="android:textSize">22sp</item>
  5. <item name="android:textColor">#0000CC</item>
  6. </style>
  7. <style name="ActivityTheme">
  8. <item name="android:windowNoTitle">true</item>
  9. </style>
  10. </resources>
在项目清单中:(应用在activity)
  1. <application
  2. android:allowBackup="true"
  3. android:icon="@drawable/ic_launcher"
  4. android:label="@string/app_name">
  5. <activity
  6. android:name="com.enterise.always.test.activity.MainActivity"
  7. android:label="@string/app_name"
  8. android:theme="@style/ActivityTheme"
  9. >
  10. <intent-filter>
  11. <action android:name="android.intent.action.MAIN" />
  12. <category android:name="android.intent.category.LAUNCHER" />
  13. </intent-filter>
  14. </activity>
  15. </application>
在项目清单中:(应用在application中)
  1. <application
  2. android:allowBackup="true"
  3. android:icon="@drawable/ic_launcher"
  4. android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
  5. android:label="@string/app_name">
@和?的使用:
@符号表明了我们应用的资源是之前有定义过的,或者是android框架中已经定义过的,我们直接对其进行使用。
?引用了当前主题中的值。
  1. <style name="ActivityTheme">
  2. <item name="android:windowNoTitle">true</item>
  3. <item name="android:windowFullscreen">?android:windowNoTitle</item>
  4. </style>
上述:
  1. ?android:windowNoTitle
引用的是name=?android:windowNoTitle的值,也就是true。
主题中:
  1. <activity
  2. android:name="com.enterise.always.test.activity.MainActivity"
  3. android:label="@string/app_name"
  4. android:theme="@style/ActivityTheme"(应用自定义样式)
  5. >
  1. <activity
  2. android:name="com.enterise.always.test.activity.MainActivity"
  3. android:label="@string/app_name"
  4. android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"(调用系统中的样式,来展示当前的activity主题)
  5. >
  1. reference--》R。style
  2. Constants
  3. int Animation                                   Base style for animations.
  4. int Animation_Activity                   Standard animations for a full-screen window or activity.
  5. int Animation_Dialog                     Standard animations for a non-full-screen window or activity.
  6. int Animation_InputMethod                    Window animations that are applied to input method overlay windows.
  7. int Animation_Toast
  8. int Animation_Translucent                    Standard animations for a translucent window or activity.
  9. int MediaButton
  10. int MediaButton_Ffwd
  11. int MediaButton_Next
  12. int MediaButton_Pause
  13. int MediaButton_Play
  14. int MediaButton_Previous
  15. int MediaButton_Rew
  16. int TextAppearance
  17. int TextAppearance_DialogWindowTitle
  18. int TextAppearance_Inverse
  19. int TextAppearance_Large
  20. int TextAppearance_Large_Inverse
  21. int TextAppearance_Medium
  22. int TextAppearance_Medium_Inverse
  23. int TextAppearance_Small
  24. int TextAppearance_Small_Inverse
  25. int TextAppearance_Theme
  26. int TextAppearance_Theme_Dialog
  27. int TextAppearance_Widget
  28. int TextAppearance_Widget_Button
  29. int TextAppearance_Widget_DropDownHint
  30. int TextAppearance_Widget_DropDownItem
  31. int TextAppearance_Widget_EditText
  32. int TextAppearance_Widget_IconMenu_Item
  33. int TextAppearance_Widget_TabWidget
  34. int TextAppearance_Widget_TextView
  35. int TextAppearance_Widget_TextView_PopupMenu
  36. int TextAppearance_Widget_TextView_SpinnerItem
  37. int TextAppearance_WindowTitle
  38. int Theme                                                    The default system theme.
  39. int Theme_Black                                Special variation on the default theme that ensures the background is completely black.
  40. int Theme_Black_NoTitleBar                         Variant of the black theme with no title bar
  41. int Theme_Black_NoTitleBar_Fullscreen          Variant of the black theme that has no title bar and fills the entire screen
  42. int Theme_Dialog                                   Default theme for dialog windows and activities, which is used by the Dialog class.
  43. int Theme_InputMethod                          Default theme for input methods, which is used by the InputMethodService class.
  44. int Theme_Light                                Theme for a light background with dark text on top.
  45. int Theme_Light_NoTitleBar                         Variant of the light theme with no title bar
  46. int Theme_Light_NoTitleBar_Fullscreen          Variant of the light theme that has no title bar and fills the entire screen
  47. int Theme_Light_Panel                          Default light theme for panel windows.
  48. int Theme_Light_WallpaperSettings                  Theme for a wallpaper's setting activity that is designed to be on top of a light background.
  49. int Theme_NoDisplay                                Default theme for activities that don't actually display a UI; that is, they finish themselves before being
  50. resumed.
  51. int Theme_NoTitleBar                           Variant of the default (dark) theme with no title bar
  52. int Theme_NoTitleBar_Fullscreen                Variant of the default (dark) theme that has no title bar and fills the entire screen
  53. int Theme_Panel                                Default dark theme for panel windows.
  54. int Theme_Translucent                          Default theme for translucent activities, that is windows that allow you to see through them to the windows
  55. behind.
  56. int Theme_Translucent_NoTitleBar                   Variant of the translucent theme with no title bar
  57. int Theme_Translucent_NoTitleBar_Fullscreen        Variant of the translucent theme that has no title bar and fills the entire screen
  58. int Theme_Wallpaper                                Default theme for windows that want to have the user's selected wallpaper appear behind them.
  59. int Theme_WallpaperSettings                        Theme for a wallpaper's setting activity that is designed to be on top of a dark background.
  60. int Theme_Wallpaper_NoTitleBar                 Variant of the translucent theme with no title bar
  61. int Theme_Wallpaper_NoTitleBar_Fullscreen          Variant of the translucent theme that has no title bar and fills the entire screen
  62. int Widget  Widget Styles
  63. int Widget_AbsListView
  64. int Widget_AutoCompleteTextView
  65. int Widget_Button
  66. int Widget_Button_Inset
  67. int Widget_Button_Small
  68. int Widget_Button_Toggle
  69. int Widget_CompoundButton
  70. int Widget_CompoundButton_CheckBox
  71. int Widget_CompoundButton_RadioButton
  72. int Widget_CompoundButton_Star
  73. int Widget_DropDownItem
  74. int Widget_DropDownItem_Spinner
  75. int Widget_EditText
  76. int Widget_ExpandableListView
  77. int Widget_Gallery
  78. int Widget_GridView
  79. int Widget_ImageButton
  80. int Widget_ImageWell
  81. int Widget_KeyboardView
  82. int Widget_ListView
  83. int Widget_ListView_DropDown
  84. int Widget_ListView_Menu
  85. int Widget_ListView_White
  86. int Widget_PopupWindow
  87. int Widget_ProgressBar
  88. int Widget_ProgressBar_Horizontal
  89. int Widget_ProgressBar_Inverse
  90. int Widget_ProgressBar_Large
  91. int Widget_ProgressBar_Large_Inverse
  92. int Widget_ProgressBar_Small
  93. int Widget_ProgressBar_Small_Inverse
  94. int Widget_RatingBar
  95. int Widget_ScrollView
  96. int Widget_SeekBar
  97. int Widget_Spinner
  98. int Widget_TabWidget
  99. int Widget_TextView
  100. int Widget_TextView_PopupMenu
  101. int Widget_TextView_SpinnerItem
  102. int Widget_WebView
  1. android:theme="@android:style/Theme.Dialog"   将一个Activity显示为对话框模式
  2. android:theme="@android:style/Theme.NoTitleBar"  不显示应用程序标题栏
  3. android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  不显示应用程序标题栏,并全屏
  4. android:theme="@android:style/Theme.Light"  背景为白色
  5. android:theme="@android:style/Theme.Light.NoTitleBar"  白色背景并无标题栏
  6. android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"  白色背景,无标题栏,全屏
  7. android:theme="@android:style/Theme.Black"  背景黑色
  8. android:theme="@android:style/Theme.Black.NoTitleBar"  黑色背景并无标题栏
  9. android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"    黑色背景,无标题栏,全屏
  10. android:theme="@android:style/Theme.Wallpaper"  用系统桌面为应用程序背景
  11. android:theme="@android:style/Theme.Wallpaper.NoTitleBar"  用系统桌面为应用程序背景,且无标题栏
  12. android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"  用系统桌面为应用程序背景,无标题栏,全屏
  13. android:theme="@android:style/Translucent"
  14. android:theme="@android:style/Theme.Translucent.NoTitleBar" 半透明,无标题
  15. android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" 半透明,无标题,全屏
  16. android:theme="@android:style/Theme.Panel" 面板风格显示
  17. android:theme="@android:style/Theme.Light.Panel" 平板风格显示
  1. <img src="http://img.blog.csdn.net/20131011150258187?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhvdWd1b3Nlbl9hbHdheXM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

版权声明:本文为博主原创文章,未经博主允许不得转载。

版权声明:本文为博主原创文章,未经博主允许不得转载。

 

android学习之-Theme和Style的更多相关文章

  1. Android开发之Theme、Style探索及源码浅析

    1 背景 前段时间群里有伙伴问到了关于Android开发中Theme与Style的问题,当然,这类东西在网上随便一搜一大把模板,所以关于怎么用的问题我想这里也就不做太多的说明了,我们这里把重点放在理解 ...

  2. Android样式(style)和主题(theme)资源介绍-android学习之旅(五十六)

    样式(style)资源 代码示例 <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...

  3. 【转】Pro Android学习笔记(二四):用户界面和控制(12):Style和Theme

    目录(?)[-] 静态格式 代码中设定 Style Theme 静态格式 在res/values中设置静态的Style,在资源中设置静态Style可使用的HTML格式有<i> <u& ...

  4. android 中theme和style的语法相关

    1.theme和style都是一组属性的集合,用于定义文本.颜色.大小等显示风格.他们都是资源,可以用android系统级别的一些默认的风格和主题资源,你也可以自定义你自己的主题和风格资源. 2.自定 ...

  5. Android 避免APP启动闪黑屏的解决办法(Theme和Style)

    前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受.没办法,只能想想怎么解决,最后找到了下面的方法.闪黑屏的原因主要是我们启动Activity的时候,需要跑完onCreate和on ...

  6. 【转】Android 避免APP启动闪黑屏(Theme和Style)

    前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受.没办法,只能想想怎么解决,最后找到了下面的方法.闪黑屏的原因主要是我们启动Activity的时候,需要跑完onCreate和on ...

  7. Android 避免APP启动闪黑屏(Theme和Style)

    前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受.没办法,只能想想怎么解决,最后找到了下面的方法.闪黑屏的原因主要是我们启动Activity的时候,需要跑完onCreate和on ...

  8. Android笔记(七十二) Style和Theme

    我们尝尝需要使用setText.setColor.setTextSize等属性来设置控件的样式,但是每个控件都需要设置这些属性,工作量无疑是巨大的,并且后期维护起来也不方便. Style Androi ...

  9. 正确使用 Android 的 Theme 和 Style

    原文:http://www.tuicool.com/articles/ZjEZFj Android 5.0 可以给一个 View 单独设置一个 theme 了,其主要用途就是用在 ToolBar 上, ...

随机推荐

  1. gerrit push配置

    第一种方法: 在home目录下,编辑.gitconfig文件,添加 [remote "review"] url = ssh://someone@oneip:port/project ...

  2. 1.Java为什么能跨平台运行?请简述原理

    因为它有虚拟机(JVM),JAVA程序不是直接在电脑上运行的,是在虚拟机上进行的,每个系统平台都是有自己的虚拟机(JVM),所以JAVA语言能跨平台. 1, java代码不是直接运行在CPU上,而是运 ...

  3. 25个超有用的 AngularJS Web 开发工具

    AngularJS是为了克服HTML在构建应用上的不足而设计的.HTML是一门很好的为静态文本展示设计的声明式语言,改善了JavaScript. 下面我要说的就是25个超有用的AngularJS工具, ...

  4. 贪心+bfs 或者 并查集 Codeforces Round #268 (Div. 2) D

    http://codeforces.com/contest/469/problem/D 题目大意: 给你一个长度为n数组,给你两个集合A.B,再给你两个数字a和b.A集合中的每一个数字x都也能在a集合 ...

  5. 最大独立集 HDU 1068

    题目大意:有n个人,两个人之间有相互的关系,问最大的关系数目. 思路:n-(最大匹配数/2).因为这里给出的是n个人之间的两两关系 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心 ...

  6. 关于Winform中的用户代理

    问题描述: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 解释: 1. 应用程序版本“Mozilla ...

  7. vim 设置默认显示行号

    vim 要默认打开的时候显示行号,这样就可以不用每次编辑的时候在手动在命令模式下:set number 来显示行号. 具体做法是: 创建一个 .vimrc的配置文件. 在启动vim时,当前用户根目录下 ...

  8. 文件系统满的话(filesystem full),该如何处理。

    #!/bin/bash function ergodic(){ ` do "/"$file ] then ergodic $"/"$file else loca ...

  9. Hibernate 系列教程10-组成关系

    组成关系 在一个员工模型里面需要存入 员工公司所在地址的城市,街道 员工籍贯所在的城市,街道, 此时可以抽取城市,街道变成一个模型即是组成关系 Employee public class Employ ...

  10. jquery 简单的栏目切换

    <style> ul{ list-style:none; padding:0px; margin:0px;} #nav_box{ width:502px; height:402px; ov ...