android5.0对app定义了一些样式,颜色、不同位置不同的属性
1、colorPrimary 应用的主要色调,actionBar默认使用该颜色,Toolbar导航栏的底色
2、colorPrimaryDark 应用的主要暗色调,statusBarColor默认使用该颜色
3、statusBarColor 状态栏颜色,默认使用colorPrimaryDark
4.windowBackground 窗口背景颜色
5.navigationBarColor 底部栏颜色
6.colorForeground 应用的前景色,ListView的分割线,switch滑动区默认使用该颜色
7.colorBackground 应用的背景色,popMenu的背景默认使用该颜色
8.colorAccent CheckBox,RadioButton,SwitchCompat等一般控件的选中效果默认采用该颜色
9.colorControlNormal CheckBox,RadioButton,SwitchCompat等默认状态的颜色。
10.colorControlHighlight 控件按压时的色调
11.colorControlActivated 控件选中时的颜色,默认使用colorAccent
12.colorButtonNormal 默认按钮的背景颜色
13.editTextColor 默认EditView输入框字体的颜色。
14.textColor Button,textView的文字颜色
15.textColorPrimary DisableOnly RadioButton checkbox等控件的文字
16.textColorPrimary 应用的主要文字颜色,actionBar的标题文字默认使用该颜色
17.colorSwitchThumbNormal: switch thumbs 默认状态的颜色. (switch off)
fitsSystemWindows属性
是否考虑系统窗口布局(系统状态栏、导航栏、输入法、底部虚拟按键等)
fitsSystemWindows=true(触发view的padding属性来给系统窗口留出空间),只有设置了透明状态栏(StatusBar)或者导航栏(NavigationBar)才会生效。
作用于4.4及以上系统,因为4.4以下系统StatusBar没有透明状态。
clipToPadding:绘制区域是否在padding里面
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="true"
tools:context=".module.StartNavigationActivity">
...
设置activity为Dialog
<style name="TestTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<!-- 设置dialog背景为黑色#00000000-->
<!-- <item name="android:windowBackground">@android:color/transparent</item>-->
<item name="android:windowNoTitle">true</item>
<!-- 是否悬浮-->
<item name="android:windowIsFloating">true</item>
<!-- 是否半透明-->
<item name="android:windowIsTranslucent">true</item>
<!-- 是否有遮盖页(白色或者黑色背景)-->
<item name="android:windowContentOverlay">@null</item>
<!-- 灰色背景-->
<item name="android:backgroundDimEnabled">true</item>
</style>
activity中设置全屏在setContentView之后设置:
// 如果不设置,则activity有边距无法充满
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
注意:Theme.AppCompat.Light.NoActionBar;
如果改为theme的继承:
<style name="TestTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
那么DecorView-->LinearLayout-->FrameLayout-->FitWindowsLinearLayout(会有个title)-->ContentFrameLayout-->RelativeLayout(自己的根布局)
虽然也会全屏透明,但是有个title。