1、java代码,在setContentView方法前调用:
SystemBarTintManager.initSystemBar(this);
SystemBarTintManager类的下载地址:点我下载
2、布局文件中:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0056ac"
android:clipToPadding="true"
android:fitsSystemWindows="true">
...标题栏写在这
</RelativeLayout>
...其他内容
</LinearLayout>
......