在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里加入

<stylename="MyTitleBar" parent="android:Theme">
<itemname="android:windowTitleSize">50dip</item>

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

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

</style>

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

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

更多相关文章

  1. Android平板大屏幕的设置
  2. Android Studio设置HTTP代理
  3. Android文件的读写
  4. Android(安卓)Launcher3主菜单背景改为黑色
  5. android中ListView拖动时背景黑色的问题
  6. Linux系统添加Android(安卓)SDK环境变量以及设置Android(安卓)St
  7. android 设置透明效果
  8. 文字跑马灯效果
  9. ListView常用属性、方法

随机推荐

  1. Windows10 20H2 IT维护人员感兴趣的一些
  2. SQL如何实现Excel的分列功能(按指定符号
  3. k8s中蓝绿部署、金丝雀发布、滚动更新汇
  4. 组件通信注解框架实践
  5. 3.14 为vCenter Server服务器添加外部DSN
  6. Prometheus基于consul服务发现
  7. 运维常见问题汇总-tomcat篇
  8. Power BI基础知识——添加列
  9. SQL高级知识V2——触发器
  10. kubernetes系列文章第一篇-k8s基本介绍