1、在style.xml中定义toolbar的颜色
<resources>
<!-- Base application theme. -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<!-- toolbar(actionbar)颜色 -->
<item name="colorPrimary">#4876FF</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="AppTheme" parent="@style/AppBaseTheme"></style>
</resources>
2、布局文件添加属性
android:fitsSystemWindows="true"
android:clipToPadding="true"
3、在Activity的onCreate(Bundle savedInstanceState)方法中添加代码
@Override
protected void onCrea