通过下面记步,可以设置应用的title与系统的通知状态栏系统的背景颜色:
1、 设置系统Theme
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
2、 在布局文件中增加v7的toolBar
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
3、 在Activity设置toolbar
@TargetApi(Build.VERSION_CODES.M)
protected void initToolbar() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
if(mToolbar == null) {
return;
}
mToolbar.setTitle(getTitle());
setSupportActionBar(mToolbar);
//
if (android.os.Build.VERSION.SDK_INT >= 21) {
Window window = getWindow();
window.setStatusBarColor(getStatusBarColor());
}
else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
final SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintColor(getStatusBarColor());
}
}
还可以设置屏幕底部的虚拟按键的背景及全屏(待处理)