AndroidTheme的设置

(2013-03-17 21:07:25) 转载
标签:

android

安卓

theme

androidmanifest

r.java

分类:Android(5/26)

在AndroidManifest.xml文件中,可以对每一个Activity设置android:theme

theme的设置 可以设置为系统自带的格式,也可以自定义格式。

A: 系统自带格式

@android:style/Theme.Black//背景黑色-有标题-非全屏
@android:style/Theme.Black.NoTitleBar//背景黑色-无标题-非全屏
@android:style/Theme.Black.NoTitleBar.Fullscreen//背景黑色-无标题-全屏显示
@android:style/Theme.Dialog //对话框显示

@android:style/Theme.InputMethod

@android:style/Theme.Light//背景白色-有标题-非全屏
@android:style/Theme.Light.NoTitleBar //背景白色-无标题-非全屏
@android:style/Theme.Light.NoTitleBar.Fullscreen //背景白色-无标题-全屏显示

@android:style/Theme.Light.Panel
@android:style/Theme.Light.WallpaperSettings //背景透明
@android:style/Theme.NoDisplay

@android:style/Theme.Translucent.NoTitleBar.Fullscreen //半透明、无标题栏、全屏

@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen

可以在单个Activity里设置,也可以在applicaiton里全局设置。比如:

<activity android:screenOrientation="portrait" android:name=".ui.RegisterActivity" android:theme="@android:style/Theme.NoTitleBar"></activity>

B:也可以自定义

在activity里加入 android:theme="@style/MyTitleBar" 再在 style.xml里加入

<style name="MyTitleBar" parent="android:Theme">
<item name="android:windowTitleSize">50dip</item>

<item name="android:windowTitleBackgroundStyle">@style/MyTitleBackground</item>
<item name="android:windowTitleStyle">@style/WindowTitle</item>
</style>

<!-- 自定义标题栏背景图 -->
<style name="MyTitleBackground" parent="android:TextAppearance.WindowTitle">
<item name="android:background">@drawable/bg_topbar</item>
</style>
<style name="WindowTitle" parent="android:TextAppearance.WindowTitle">
<item name="android:singleLine">true</item>

</style>

这里的parent是继承于android:Theme,所以在下面的样式里,只能是window开头的样式才起作用,所有样式请参考\sdk\docs\reference\android\R.attr.html,

也可以设置windowTitleBackgroundStyle 为@style/MyTitleBackground,这样就可以在MyTitleBackground里,设置背景图啦,

更多相关文章

  1. Android设置Activity背景为透明style
  2. Android 设置圆角背景
  3. android预定义样式简述
  4. Android:res之selector背景选择器
  5. 如何将Activity设置为Dialog样式
  6. Android图表控件MPAndroidChart——LineChart实现 XY轴、原点线
  7. android设置透明背景
  8. android 4.2修改设置菜单的背景颜色
  9. Android selector(背景选择器) , shape(设定形状)

随机推荐

  1. python全栈+爬虫+自动化+AI=python全能工
  2. 茅台招聘刷爆资管圈,量化巨佬钦点DolphinD
  3. WebStorm激活码最新2021,WebStorm破解详细
  4. 玩转N种企业级解决方案,笑傲分布式开发
  5. 白话解读 WebRTC 音频 NetEQ 及优化实践
  6. 时空212生成后问题
  7. 运维助力敏捷交付-我们的运维看板
  8. DevOps 三剑客:Dev,Ops and Jenkins
  9. 流媒体服务器(视频服务器)实现超大并发的解
  10. mysql