android学习之-Theme和Style
android style和theme的使用。
style:样式,用来描述单独的view控件,改变其样式。
theme:主题,用来控制整个应用的主题,或者某个activity的主题。
style的使用:改变某控件的样式。
在style.xml中描述样式信息
1. <?xml version="1.0" encoding="utf-8"?>
2. <resources>
3.
4. "TextAttr">
5. "android:textSize">22sp</item>
6. "android:textColor">#0000CC</item>
7. </style>
8.
9. </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.
4. "TextAttr">
5. "android:textSize">22sp</item>
6. "android:textColor">#0000CC</item>
7. </style>
8.
9. "ActivityTheme">
10. "android:windowNoTitle">true</item>
11. </style>
12.
13. </resources>
在项目清单中:(应用在activity)
1. <application
2. "true"
3. "@drawable/ic_launcher"
4. "@string/app_name">
5. <activity
6. "com.enterise.always.test.activity.MainActivity"
7. "@string/app_name"
8. "@style/ActivityTheme"
9. >
10. <intent-filter>
11. "android.intent.action.MAIN" />
12. "android.intent.category.LAUNCHER" />
13. </intent-filter>
14. </activity>
15.
16. </application>
在项目清单中:(应用在application中)
1. <application
2. "true"
3. "@drawable/ic_launcher"
4. "@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
5. "@string/app_name">
@和?的使用:
@符号表明了我们应用的资源是之前有定义过的,或者是android框架中已经定义过的,我们直接对其进行使用。
?引用了当前主题中的值。
1. <style name="ActivityTheme">
2. "android:windowNoTitle">true</item>
3. "android:windowFullscreen">?android:windowNoTitle</item>
4. </style>
上述:
1. ?android:windowNoTitle
引用的是name=?android:windowNoTitle的值,也就是true。
主题中:
1. <activity
2. "com.enterise.always.test.activity.MainActivity"
3. "@string/app_name"
4. "@style/ActivityTheme"(应用自定义样式)
5. >
1. <activity
2. "com.enterise.always.test.activity.MainActivity"
3. "@string/app_name"
4. "@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.
51. resumed.
52. int Theme_NoTitleBar Variant of the default (dark) theme with no title bar
53. int Theme_NoTitleBar_Fullscreen Variant of the default (dark) theme that has no title bar and fills the entire screen
54. int Theme_Panel Default dark theme for panel windows.
55. int Theme_Translucent Default theme for translucent activities, that is windows that allow you to see through them to the windows
56.
57. behind.
58. int Theme_Translucent_NoTitleBar Variant of the translucent theme with no title bar
59. int Theme_Translucent_NoTitleBar_Fullscreen Variant of the translucent theme that has no title bar and fills the entire screen
60. int Theme_Wallpaper Default theme for windows that want to have the user's selected wallpaper appear behind them.
61. int Theme_WallpaperSettings Theme for a wallpaper's setting activity that is designed to be on top of a dark background.
62. int Theme_Wallpaper_NoTitleBar Variant of the translucent theme with no title bar
63. int Theme_Wallpaper_NoTitleBar_Fullscreen Variant of the translucent theme that has no title bar and fills the entire screen
64. int Widget Widget Styles
65. int Widget_AbsListView
66. int Widget_AutoCompleteTextView
67. int Widget_Button
68. int Widget_Button_Inset
69. int Widget_Button_Small
70. int Widget_Button_Toggle
71. int Widget_CompoundButton
72. int Widget_CompoundButton_CheckBox
73. int Widget_CompoundButton_RadioButton
74. int Widget_CompoundButton_Star
75. int Widget_DropDownItem
76. int Widget_DropDownItem_Spinner
77. int Widget_EditText
78. int Widget_ExpandableListView
79. int Widget_Gallery
80. int Widget_GridView
81. int Widget_ImageButton
82. int Widget_ImageWell
83. int Widget_KeyboardView
84. int Widget_ListView
85. int Widget_ListView_DropDown
86. int Widget_ListView_Menu
87. int Widget_ListView_White
88. int Widget_PopupWindow
89. int Widget_ProgressBar
90. int Widget_ProgressBar_Horizontal
91. int Widget_ProgressBar_Inverse
92. int Widget_ProgressBar_Large
93. int Widget_ProgressBar_Large_Inverse
94. int Widget_ProgressBar_Small
95. int Widget_ProgressBar_Small_Inverse
96. int Widget_RatingBar
97. int Widget_ScrollView
98. int Widget_SeekBar
99. int Widget_Spinner
100. int Widget_TabWidget
101. int Widget_TextView
102. int Widget_TextView_PopupMenu
103. int Widget_TextView_SpinnerItem
104. 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" 平板风格显示
- http://www.linuxidc.com/Linux/2011-08/41087.htm