android的theme
1. 安卓手机如何打开.theme文件
打开文件管理,找到系统文件夹,打开,在theme这个文件里。打开系统文件就可以看到。theme 是WINDOWS自带的桌面壁纸文件,用于存放桌面图形文件。
2. Android中style和theme的区别
Theme 和Style资源,将一些通用的属性提取出来,方便使用。
相同:
Theme和Style位于values文件夹下styles.xml下,格式相同。
[java] view plain
<style name="MyTransparent">
<item name="android:windowBackground">@color/transparent_background</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<item name="Android:windowNoTitle">?android:windowIsTranslucent</item>其中 问号表示引用本主题中已经定义过的资源的值。
在需要使用的时候调用
[java] view plain
<EditText
android:id="@+id/nameEdit"
<span style="color:#ff0000;"> style="@style/LoginOrRegisterEditStyle"</span>
android:hint="@string/input_real_name"
android:layout_below="@id/tipHead"
android:layout_marginTop="20dp" />
不同:
Theme在AndroidManifest.xml中德Application节点或者Activity节点设置android:theme,或者在对应Activity中通过代码设置setTheme(),影响整个应用或者一个Activity.
Style一般是在布局中的View中设置。影响单个View,如EditText,TextView等等。
如果主题和样式属性有冲突,样式的属性高于主题。
如果需要使用系统自带的主题
[java] view plain
android:theme=<span style="color:#ff0000;">"@android:style</span>/Theme.Light.NoTitleBar"
3. Android常见主题
android:theme="@android:style/Theme.Dialog" //Activity显示为对话框模式
android:theme="@android:style/Theme.NoTitleBar" //不显示应用程序标题栏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" //不显示应用程序标题栏,并全屏
android:theme="Theme.Light " //背景为白色
android:theme="Theme.Light.NoTitleBar" //白色背景并无标题栏
android:theme="Theme.Light.NoTitleBar.Fullscreen" //白色背景,无标题栏,全屏
android:theme="Theme.Black" //背景黑色
android:theme="Theme.Black.NoTitleBar" //黑色背景并无标题栏
android:theme="Theme.Black.NoTitleBar.Fullscreen" //黑色背景,无标题栏,全屏
android:theme="Theme.Wallpaper" //用系统桌面为应用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" //用系统桌面为应用程序背景,且无标题栏
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" //用系统桌面为应用程序背景,无标题栏,全屏
android:theme="Theme.Translucent" //透明背景
android:theme="Theme.Translucent.NoTitleBar" //透明背景并无标题
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" //透明背景并无标题,全屏
android:theme="Theme.Panel " //面板风格显示
android:theme="Theme.Light.Panel" //平板风格显示
4. Android开发主题样式详解
application标签中的@style/AppTheme引用自哪个文件夹中的styles.xml,这是根据运行此程序的手机系统来决定的,如果手机系统的API版本是11以上就是v11/styles.xml,API版本是14以上就是v14/styles.xml,以此类推。我们可以通过修改AppBaseTheme的父主题来实现我们需要的样式,此文章主要就是来讨论这个主题如何修改。
使用android系统中自带的主题要加上"android:",如:android:Theme.Black
使用v7兼容包中的主题不需要前缀,如:Theme.AppCompat
系统自带主题:
API 1:
android:Theme 根主题
android:Theme.Black 背景黑色
android:Theme.Light 背景白色
android:Theme.Wallpaper 以桌面墙纸为背景
android:Theme.Translucent 透明背景
android:Theme.Panel 平板风格
android:Theme.Dialog 对话框风格
API 11:
android:Theme.Holo Holo根主题
android:Theme.Holo.Black Holo黑主题
android:Theme.Holo.Light Holo白主题
API 14:
android:Theme.DeviceDefault 设备默认根主题
android:Theme.DeviceDefault.Black 设备默认黑主题
android:Theme.DeviceDefault.Light 设备默认白主题
API 21: (网上常说的 Android Material Design 就是要用这种主题)
android:Theme.Material Material根主题
android:Theme.Material.Light Material白主题
兼容包v7中带的主题:
Theme.AppCompat 兼容主题的根主题
Theme.AppCompat.Black 兼容主题的黑色主题
Theme.AppCompat.Light 兼容主题的白色主题
以下都是指“包含”,比如包含“Dialog”表示对话框风格
比如Theme.Dialog、Theme.Holo.Dialog、Theme.Material.Dialog、Theme.AppCompat.Dialog都是对话框风格
Black 黑色风格
Light 光明风格
Dark 黑暗风格
DayNight 白昼风格
Wallpaper 墙纸为背景
Translucent 透明背景
Panel 平板风格
Dialog 对话框风格
NoTitleBar 没有TitleBar
NoActionBar 没有ActionBar
Fullscreen 全屏风格
MinWidth 对话框或者ActionBar的宽度根据内容变化,而不是充满全屏
WhenLarge 对话框充满全屏
TranslucentDecor 半透明风格
NoDisplay 不显示,也就是隐藏了
WithActionBar 在旧版主题上显示ActionBar
5. Android 的style和theme
例子
Theme是针对窗体级别的,改变窗体样式;
Style是针对窗体元素级别的,改变指袜仿定控件或者Layout的样式
简单的说就是Theme里面有包含了好多好多Style
常用于Toolbar下
比如
android:theme="@style/AppTheme.AppBarOverlay设置了Toolbar的主题
app:popupTheme="@style/AppTheme.PopupOverlay"设置了Toolbar节点下的view的主题
默认瞎好简情况下我们使用theme为android:Theme.Holo.Light.DarkActionBar那么ActionBar文字是白的,ActionBar Overflow弹出的是黑底白字,如果需求是白磨裤底黑字那么只要设置toolbar的app:popupTheme="ThemeOverlay.AppCompat.Light"
附上一张官方的
装载自 关于Android的style和theme
6. Android系统自带样式Theme总结
本文从网上复制,给自己做笔记的,摘自: http://blog.csdn.net/hongya1109110121/article/details/11985545
Android系统自带样式(@android:style/) (转)
1 android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
布局页面最上面 不会显示 android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。
2 android:theme="@style/AppTheme"
布局页面最上面 显示 android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。
其他
在数嫌并AndroidManifest.xml文件的activity中配置
1、android:theme="@android:style/Theme"
默认状态,即如果theme这里不填任何属性的时候,默认为Theme
2、android:theme="@android:style/Theme.NoDisplay"
任何都不显示。比较适用于只是运行了activity,但未显示任何东西
3、android:theme="@android:style/Theme.NoTitleBar“
背景主题的没有标题栏者岩的样式,默认如果没有设置的话,显示黑背景
4、android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
背景主题的没有标题栏且全屏的样式,默认为黑背景
5、android:theme="@android:style/Theme.Black"
默认状态下黑背景
6、android:theme="@android:style/Theme.Black.NoTitleBar"
黑背景主题的没有标题栏的样式
7、android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
黑背景主题的没有标题栏且全屏的样式
8、薯迹android:theme="@android:style/Theme.Light"
默认状态下亮背景,与上述黑背景Theme.Black相反
9、android:theme="@android:style/Theme.Light.NoTitleBar"
亮背景主题的没有标题栏的样式,与Theme.Black.NoTitleBar相反
10、android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
亮背景主题的没有标题栏且全屏显示的样式,与Theme.Black.NoTitleBa.Fullscreenr相反
11、android:theme="@android:style/Theme.Dialog"
对话框样式 将整个activity变成对话框样式出现
12、android:theme="@android:style/Theme.InputMethod"
Window animations that are applied to input method overlay windows
13、android:theme="@android:style/ Theme.Panel"
删除掉所有多余的窗口装饰,在一个空的矩形框中填充内容,作用范围相当于把dialog中的所有元素全部去掉,只是一个空的矩形框,且此为默认的样式
14、android:theme="@android:style/ Theme.Light.Panel"
删除掉所有多余的窗口装饰,在一个空的矩形框中填充内容,作用范围相当于把dialog中的所有元素全部去掉,只是一个空的矩形框,且默认是light的样式
15、android:theme="@android:style/Theme.Wallpaper"
使用墙纸做主题,默认状态。
16、android:theme="@android:style/ Theme.WallpaperSettings"
使用墙纸做主题,默认是使用将上一个界面调暗之后作为主题
17、android:theme="@android:style/ Theme.Light.WallpaperSettings"
使用墙纸做主题,默认Light状态
18、android:theme="@android:style/Theme.Wallpaper.NoTitleBar"
使用墙纸做主题,且没有标题栏
19、android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
使用墙纸做主题,且没有标题栏,且全屏显示
20、android:theme="@android:style/Theme.Translucent"
半透明状态下的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。
21、android:theme="@android:style/Theme.Translucent.NoTitleBar"
半透明状态下没有标题栏的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。
22、android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
半透明状态下没有标题栏且全屏的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。
摘自: http://blog.csdn.net/hongya1109110121/article/details/11985545