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>
上述:
引用的是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主题)
- >
- 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