android学习之-Theme和Style
android style和theme的使用。
style:样式,用来描述单独的view控件,改变其样式。
theme:主题,用来控制整个应用的主题,或者某个activity的主题。 style的使用:改变某控件的样式。
在style.xml中描述样式信息
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <style name="TextAttr">
- <item name="android:textSize">22sp</item>
- <item name="android:textColor">#0000CC</item>
- </style>
- </resources>
在控件(TextView,EditText,Layout)中使用控件来显示其样式。
<TextView
style="@style/TextAttr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="样式" />
Theme的使用,用来改变窗体的展示。
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <style name="TextAttr">
- <item name="android:textSize">22sp</item>
- <item name="android:textColor">#0000CC</item>
- </style>
- <style name="ActivityTheme">
- <item name="android:windowNoTitle">true</item>
- </style>
- </resources>
在项目清单中:(应用在activity)
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name">
- <activity
- android:name="com.enterise.always.test.activity.MainActivity"
- android:label="@string/app_name"
- android:theme="@style/ActivityTheme"
- >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
在项目清单中:(应用在application中)
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
- android:label="@string/app_name">
@和?的使用:
@符号表明了我们应用的资源是之前有定义过的,或者是android框架中已经定义过的,我们直接对其进行使用。
?引用了当前主题中的值。
- <style name="ActivityTheme">
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowFullscreen">?android:windowNoTitle</item>
- </style>
上述:
- ?android:windowNoTitle
引用的是name=?android:windowNoTitle的值,也就是true。
主题中:
- <activity
- android:name="com.enterise.always.test.activity.MainActivity"
- android:label="@string/app_name"
- android:theme="@style/ActivityTheme"(应用自定义样式)
- >
- <activity
- android:name="com.enterise.always.test.activity.MainActivity"
- android:label="@string/app_name"
- android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"(调用系统中的样式,来展示当前的activity主题)
- >
- reference--》R。style
- Constants
- int Animation Base style for animations.
- int Animation_Activity Standard animations for a full-screen window or activity.
- int Animation_Dialog Standard animations for a non-full-screen window or activity.
- int Animation_InputMethod Window animations that are applied to input method overlay windows.
- int Animation_Toast
- int Animation_Translucent Standard animations for a translucent window or activity.
- int MediaButton
- int MediaButton_Ffwd
- int MediaButton_Next
- int MediaButton_Pause
- int MediaButton_Play
- int MediaButton_Previous
- int MediaButton_Rew
- int TextAppearance
- int TextAppearance_DialogWindowTitle
- int TextAppearance_Inverse
- int TextAppearance_Large
- int TextAppearance_Large_Inverse
- int TextAppearance_Medium
- int TextAppearance_Medium_Inverse
- int TextAppearance_Small
- int TextAppearance_Small_Inverse
- int TextAppearance_Theme
- int TextAppearance_Theme_Dialog
- int TextAppearance_Widget
- int TextAppearance_Widget_Button
- int TextAppearance_Widget_DropDownHint
- int TextAppearance_Widget_DropDownItem
- int TextAppearance_Widget_EditText
- int TextAppearance_Widget_IconMenu_Item
- int TextAppearance_Widget_TabWidget
- int TextAppearance_Widget_TextView
- int TextAppearance_Widget_TextView_PopupMenu
- int TextAppearance_Widget_TextView_SpinnerItem
- int TextAppearance_WindowTitle
- int Theme The default system theme.
- int Theme_Black Special variation on the default theme that ensures the background is completely black.
- int Theme_Black_NoTitleBar Variant of the black theme with no title bar
- int Theme_Black_NoTitleBar_Fullscreen Variant of the black theme that has no title bar and fills the entire screen
- int Theme_Dialog Default theme for dialog windows and activities, which is used by the Dialog class.
- int Theme_InputMethod Default theme for input methods, which is used by the InputMethodService class.
- int Theme_Light Theme for a light background with dark text on top.
- int Theme_Light_NoTitleBar Variant of the light theme with no title bar
- int Theme_Light_NoTitleBar_Fullscreen Variant of the light theme that has no title bar and fills the entire screen
- int Theme_Light_Panel Default light theme for panel windows.
- int Theme_Light_WallpaperSettings Theme for a wallpaper's setting activity that is designed to be on top of a light background.
- int Theme_NoDisplay Default theme for activities that don't actually display a UI; that is, they finish themselves before being
- resumed.
- int Theme_NoTitleBar Variant of the default (dark) theme with no title bar
- int Theme_NoTitleBar_Fullscreen Variant of the default (dark) theme that has no title bar and fills the entire screen
- int Theme_Panel Default dark theme for panel windows.
- int Theme_Translucent Default theme for translucent activities, that is windows that allow you to see through them to the windows
- behind.
- int Theme_Translucent_NoTitleBar Variant of the translucent theme with no title bar
- int Theme_Translucent_NoTitleBar_Fullscreen Variant of the translucent theme that has no title bar and fills the entire screen
- int Theme_Wallpaper Default theme for windows that want to have the user's selected wallpaper appear behind them.
- int Theme_WallpaperSettings Theme for a wallpaper's setting activity that is designed to be on top of a dark background.
- int Theme_Wallpaper_NoTitleBar Variant of the translucent theme with no title bar
- int Theme_Wallpaper_NoTitleBar_Fullscreen Variant of the translucent theme that has no title bar and fills the entire screen
- int Widget Widget Styles
- int Widget_AbsListView
- int Widget_AutoCompleteTextView
- int Widget_Button
- int Widget_Button_Inset
- int Widget_Button_Small
- int Widget_Button_Toggle
- int Widget_CompoundButton
- int Widget_CompoundButton_CheckBox
- int Widget_CompoundButton_RadioButton
- int Widget_CompoundButton_Star
- int Widget_DropDownItem
- int Widget_DropDownItem_Spinner
- int Widget_EditText
- int Widget_ExpandableListView
- int Widget_Gallery
- int Widget_GridView
- int Widget_ImageButton
- int Widget_ImageWell
- int Widget_KeyboardView
- int Widget_ListView
- int Widget_ListView_DropDown
- int Widget_ListView_Menu
- int Widget_ListView_White
- int Widget_PopupWindow
- int Widget_ProgressBar
- int Widget_ProgressBar_Horizontal
- int Widget_ProgressBar_Inverse
- int Widget_ProgressBar_Large
- int Widget_ProgressBar_Large_Inverse
- int Widget_ProgressBar_Small
- int Widget_ProgressBar_Small_Inverse
- int Widget_RatingBar
- int Widget_ScrollView
- int Widget_SeekBar
- int Widget_Spinner
- int Widget_TabWidget
- int Widget_TextView
- int Widget_TextView_PopupMenu
- int Widget_TextView_SpinnerItem
- int Widget_WebView
- android:theme="@android:style/Theme.Dialog" 将一个Activity显示为对话框模式
- android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不显示应用程序标题栏,并全屏
- android:theme="@android:style/Theme.Light" 背景为白色
- android:theme="@android:style/Theme.Light.NoTitleBar" 白色背景并无标题栏
- android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏
- android:theme="@android:style/Theme.Black" 背景黑色
- android:theme="@android:style/Theme.Black.NoTitleBar" 黑色背景并无标题栏
- android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏
- android:theme="@android:style/Theme.Wallpaper" 用系统桌面为应用程序背景
- android:theme="@android:style/Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,且无标题栏
- android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏
- android:theme="@android:style/Translucent"
- android:theme="@android:style/Theme.Translucent.NoTitleBar" 半透明,无标题
- android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" 半透明,无标题,全屏
- android:theme="@android:style/Theme.Panel" 面板风格显示
- android:theme="@android:style/Theme.Light.Panel" 平板风格显示
- <img src="http://img.blog.csdn.net/20131011150258187?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhvdWd1b3Nlbl9hbHdheXM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
版权声明:本文为博主原创文章,未经博主允许不得转载。
版权声明:本文为博主原创文章,未经博主允许不得转载。
- 上一篇android学习之-Junit测试
- 下一篇设计模式之--单例(Singleton)
- http://www.cnblogs.com/linlf03/archive/2013/03/14/2959164.html
- http://blog.csdn.net/zhouguosen_always/article/details/12616593
- http://www.linuxidc.com/Linux/2011-08/41087.htm
- http://www.cnblogs.com/tinyphp/p/3826098.html
android学习之-Theme和Style的更多相关文章
- Android开发之Theme、Style探索及源码浅析
1 背景 前段时间群里有伙伴问到了关于Android开发中Theme与Style的问题,当然,这类东西在网上随便一搜一大把模板,所以关于怎么用的问题我想这里也就不做太多的说明了,我们这里把重点放在理解 ...
- Android样式(style)和主题(theme)资源介绍-android学习之旅(五十六)
样式(style)资源 代码示例 <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...
- 【转】Pro Android学习笔记(二四):用户界面和控制(12):Style和Theme
目录(?)[-] 静态格式 代码中设定 Style Theme 静态格式 在res/values中设置静态的Style,在资源中设置静态Style可使用的HTML格式有<i> <u& ...
- android 中theme和style的语法相关
1.theme和style都是一组属性的集合,用于定义文本.颜色.大小等显示风格.他们都是资源,可以用android系统级别的一些默认的风格和主题资源,你也可以自定义你自己的主题和风格资源. 2.自定 ...
- Android 避免APP启动闪黑屏的解决办法(Theme和Style)
前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受.没办法,只能想想怎么解决,最后找到了下面的方法.闪黑屏的原因主要是我们启动Activity的时候,需要跑完onCreate和on ...
- 【转】Android 避免APP启动闪黑屏(Theme和Style)
前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受.没办法,只能想想怎么解决,最后找到了下面的方法.闪黑屏的原因主要是我们启动Activity的时候,需要跑完onCreate和on ...
- Android 避免APP启动闪黑屏(Theme和Style)
前几天Boss就反应说,机器每次启动程序都会闪一下黑屏,这个客户不接受.没办法,只能想想怎么解决,最后找到了下面的方法.闪黑屏的原因主要是我们启动Activity的时候,需要跑完onCreate和on ...
- Android笔记(七十二) Style和Theme
我们尝尝需要使用setText.setColor.setTextSize等属性来设置控件的样式,但是每个控件都需要设置这些属性,工作量无疑是巨大的,并且后期维护起来也不方便. Style Androi ...
- 正确使用 Android 的 Theme 和 Style
原文:http://www.tuicool.com/articles/ZjEZFj Android 5.0 可以给一个 View 单独设置一个 theme 了,其主要用途就是用在 ToolBar 上, ...
随机推荐
- LeetCode OJ 222. Count Complete Tree Nodes
Total Accepted: 32628 Total Submissions: 129569 Difficulty: Medium Given a complete binary tree, cou ...
- 修改一个Label上字体的大小(富文本)
假如修改上面的Label上价格30000的大小,那么需要用到富文本 上代码 // 字符串30000 NSString * priceNumber = @"30000"; [pric ...
- Xcode6无法用xib得问题解决方法
1.创建一个新工程,选择singleView application 2.将storyboard和launchscreen删除,选择moveToTrash 3.删除info.plist文件中Main ...
- EF中用Newtonsoft.Json引发的循环引用问题
描述: 1.双向关系表a->b b->aList 2.在查询a引用b以后 3.用Newtonsoft.Json 去tojsonstring 4.一个只有6条数据的json串 出现了一屏幕字 ...
- AJAX程序实验
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 < ...
- Android Service学习之IntentService 深入分析
什么是IntentService? (本文转自http://blog.csdn.net/gaojie314/archive/2010/11/28/6040701.aspx) 官方的解释是: ...
- Industry Engineer
IE:有两种,一种是系统方面的,对全厂的物流设计,依据产量做人力估算,机台,设备,手工具的估算等,一种是配合产能提升做制造的改善,以及SOP(Standard Operation Procedure: ...
- 工控中的windows
今后的windows如何在工业应用中发展,之前的windows如何保证安全的运行,如果只专注于消费,生产上是否还需要windows,如果那样,windows真的只有windows了
- 打不开BT,一直重复的关闭开启。
/bt-btif (25335): ...preload_wait_timeout (retried:0/max-retry:1)...D/bt_userial(25335): RX terminat ...
- 我眼中的C#3.0 摘自于网络:http://www.cnblogs.com/joinger/articles/1297237.html
每次有新技术发布时,我们总能感受到两种截然不同的情绪: 一种是恐惧和抵抗,伴随着这种情绪的还有诸如"C# 2.0用的挺好的,为什么要在C# 3.0搞到那么复杂?"或者"我 ...