系统自带主题

将样式代码放置在应用的AndroidManifest.xml的activity中,代码格式为:

android:theme="@android:style/Theme.Dialog"

或者在onCreate()setContentView()之前调用setTheme()函数:

setTheme(R.style.Theme_Dialog);

Theme.Dialog : Activity显示为对话框模式

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.Translucent : 透明背景
Theme.Translucent.NoTitleBar : 透明背景并无标题
Theme.Translucent.NoTitleBar.Fullscreen : 透明背景并无标题,全屏

Theme.Panel : 面板风格显示
Theme.Light.Panel : 平板风格显示

自定义主题

项目的 res / value 目录下建立xml文件:mytheme.xml 内容如下

<?xml version="1.0" encoding="utf-8"?><resources><style name="mytheme" parent="android:Theme.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:textSize">20sp</item> <item name="android:textColor">#000000</item> </style></resources>

注:
parent 属性用来继承,我们这个主题就继承自android提供的Dialog主题
然后在这个基础上实现 android:windowNoTitle,也就是不显示标题栏,加上字体大小,字体颜色……
在 AndroidManifest.xml 里使用你创建的主题:

<activity android:name=".MainActivity" android:theme="@style/mytheme"/>

或者在onCreate()setContentView()之前调用setTheme()函数:

setTheme(R.style.mytheme);

转载自:http://blog.sina.com.cn/s/blog_627ebfc3010119ih.html

更多相关文章

  1. Android中主题的添加
  2. Android应用程序的权限列表
  3. [入门]Android的应用程序框架
  4. Android应用程序剖析
  5. android shape设置背景风格为圆角
  6. Android边框背景
  7. 最全的PHP开发Android应用程序

随机推荐

  1. Android(安卓)屏幕分辩率相关问题
  2. Android开发资源 汇总
  3. Android完美解决输入框EditText隐藏密码
  4. Android(安卓)实用工具Hierarchy Viewer
  5. Android(安卓)属性动画(一):Animator属性动
  6. Google Maps 工程的小问题
  7. Android有用代码片段(二)
  8. Android(安卓)LayoutInflater原理分析,带
  9. Android(安卓)Animation学习笔记
  10. Android自定义Button按钮显示样式