对整个APP设置,如
<application android:label="@string/app_name" android:icon="@drawable/heart"
android:name=".config.MyApplication"
android:theme="@style/BaseStyle"
>
对单个Activity页面设置:
<activity android:name=".activity.MyActivity"
android:label="@string/app_name"
android:theme="@style/MyStyle"
>
但是要注意一个Application或Activity只能设置一个theme,如果要设置多个样式的值还是要设置style!不要忘记前面的android:,因为这个是android系统提供的
1、安卓状态栏和标题栏修改背景色还字体颜色,在style.xml里面修改,如:
<!-- 隐藏标题栏(如果设置导航栏的沉浸,这个是必须的) -->
<item name="windowNoTitle">true</item>
<!-- 设置为透明,(该属性只有在在4.4和高于4.4版本上可以进行该属性的配置,但是在更低版本上则无法使用) -->
<item name="android:windowTranslucentStatus">true</item>
android:windowNoTitle 设置有没有标题栏true|false
android:windowFullScreen 设置全屏true|false
droid:windowIsFloating 设置是否浮现在activity之上true|false
android:windowIsTranslucent 设置window是否为透明
android:windowBackground 设置window的背景颜色
android:windowContentOverlay这个是定义contentoverlay的背景的
android:windowTranslucentNavigation" 设置为true|false,对底部的导航按钮有影响,最好不用
2、如果去除顶部title和状态栏,直接把parent改为NoActionBar:
二、直接在AndroidManifest.xml中根据需要在或中使用自定义的Android主题方式进行设置:
android:theme="@style/theme_fullScreen"
窗口主题设置:(这里主要对于Activity设置,用到系统自动主题内容)
android:theme="@android:style/Theme.Dialog" : Activity显示为对话框模式
android:theme="@android:style/Theme.NoTitleBar" : 不显示应用程序标题栏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" : 不显示应用程序标题栏,并全屏
android:theme="@android:style/Theme.Light": 背景为白色
android:theme="@android:style/Theme.Light.NoTitleBar" : 白色背景并无标题栏
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" : 白色背景,无标题栏,全屏
android:theme="@android:style/Theme.Black" : 背景黑色
android:theme="@android:style/Theme.Black.NoTitleBar" : 黑色背景并无标题栏
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" : 黑色背景,无标题栏,全屏
android:theme="@android:style/Theme.Wallpaper" : 用系统桌面为应用程序背景
android:theme="@android:style/Theme.Wallpaper.NoTitleBar" : 用系统桌面为应用程序背景,且无标题栏
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen" : 用系统桌面为应用程序背景,无标题栏,全屏
android:theme="@android:style/Theme.Translucent : 透明背景
android:theme="@android:style/Theme.Translucent.NoTitleBar" : 透明背景并无标题
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" : 透明背景并无标题,全屏
android:theme="@android:style/Theme.Panel ": 面板风格显示
android:theme="@android:style/Theme.Light.Panel" : 平板风格显示
整个界面可以看做是一个window,fitsSystemWindows 生效的前提是状态栏(StatusBar)或导航栏(NavigationBar)透明并且不能有标题栏,默认fitsSystemWindows = true,表示页面布局(内容区)不会扩展到状态栏,会针对透明的状态栏会自动添加一个值等于状态栏高度的paddingTop;针对透明的系统导航栏会自动添加一个值等于导航栏高度的paddingBottom,当fitsSystemWindows = false时,表示页面布局(内容区)扩展到状态栏,设置代码如下:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!--透明状态栏-->
<item name="android:windowTranslucentStatus">true</item>
</style>
android:fitsSystemWindows="false"