Android自带的一些可用于Activity的Theme
来源:互联网 发布:python api文档在哪有 编辑:程序博客网 时间:2024/05/02 06:08
http://kurtchen.com/blog/2010/03/10/android-theme/
在 AndroidMenifest.xml 中定义 Activity 的时候我们可以使用 android:theme 来设置 Activity 的主题,比如:
<
activity
android:name
=
".MainActivity"
android:label
=
"@string/app_name"
android:theme
=
"@android:style/Theme.NoTitleBar"
>
Android 本身自带了一些 Theme ,可以在frameworks/base/core/res/res/values/themes.xml中找到,从这个文件中也能看到默认的Theme是如何定义的(Theme)。
Theme
Theme.NoTitleBar
Theme.NoTitleBar.Fullscreen
Theme.Light
Theme.Light.NoTitleBar
Theme.Light.NoTitleBar.Fullscreen
Theme.Black
Theme.Black.NoTitleBar
Theme.Black.NoTitleBar.Fullscreen
Theme.Wallpaper
Theme.Wallpaper.NoTitleBar
Theme.Wallpaper.NoTitleBar.Fullscreen
Theme.WallpaperSettings
Theme.Light.WallpaperSettings
Theme.Translucent
Theme.Translucent.NoTitleBar
Theme.Translucent.NoTitleBar.Fullscreen
Theme.Dialog
Theme.Panel
Theme.Light.Panel
Theme.InputMethod
其中有一个比较有意思的是 Theme.NoDisplay :
Default theme for activities that don’t actually display a UI; that is, they finish themselves before being resumed.
还有几个不知道为什么是不能使用的(#TODO),比如 Theme.Dialog.Alert ,会报错:
Error: Resource is not public. (at ‘theme’ with value ‘@android:style/Theme.Dialog.Alert’)
colors.xml
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
resources
>
<
drawable
name
=
"green_background"
>#ff00ff00</
drawable
>
</
resources
>
theme.xml
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
resources
>
<
style
name
=
"MyTheme"
>
<
item
name
=
"android:windowBackground"
>@drawable/green_background</
item
>
</
style
>
</
resources
>
Activity
<
activity
android:name
=
".MainActivity"
android:label
=
"@string/app_name"
android:theme
=
"@style/MyTheme"
>
再举个例子,比如在 theme.xml 中 Theme.Dialog.Alert 不给我们用,我们可以自己定义一份拿来使用:
<
style
name
=
"MyDialog"
>
<
item
name
=
"android:windowBackground"
>@android:color/transparent</
item
>
<
item
name
=
"android:windowTitleStyle"
>@style/DialogWindowTitle</
item
>
<
item
name
=
"android:windowIsFloating"
>true</
item
>
<
item
name
=
"android:windowContentOverlay"
>@null</
item
>
</
style
>
<
style
name
=
"DialogWindowTitle"
>
<
item
name
=
"android:maxLines"
>1</
item
>
<
item
name
=
"android:scrollHorizontally"
>true</
item
>
<
item
name
=
"android:textAppearance"
>
@android:style/TextAppearance.DialogWindowTitle
</
item
>
</
style
>
- Android 自带的一些可用于Activity的Theme
- Android自带的一些可用于Activity的Theme
- android 自带的主题theme
- Android自带的Theme主题图解
- android Activity的 theme
- android笔记:安卓自带的主题android:theme
- android笔记:安卓自带的主题android:theme
- android笔记:安卓自带的主题android:theme
- android 自带的主题 theme 的使用
- android 自带的主题 theme 的使用
- android 自带的主题 theme 的使用
- 安卓自带的主题android:theme
- Activity设置全屏显示的两种方式及系统自带theme属性解析
- 探究activity自带的一些判断方法
- Android系统自带theme
- android自带样式 theme
- android自带样式 theme
- Android-自带Theme样式
- Struts1.x系列教程(14):动态Form
- JQuery中each()与toggleClass()使用
- vc6.0+wxSqlite3编译成静态库总结
- 小心使用STL中map的[]操作符[转]
- MVN
- Android自带的一些可用于Activity的Theme
- Linux下网站的验证码图片不显示
- Struts1.x系列教程(15):使用DownloadAction类统计文件下载次数
- 信息设计软件+信息图表设计软件介绍
- 开始写博客
- Struts1.x系列教程(16):使用LocaleAction类实现国际化的Web程序
- 英语精读001-How to Improve Your Study Habits
- java 类的变量 和 静态变量 的初始化
- Android笔记(4)——android 颜色值 xml