一行代码实现沉浸式状态栏

第一步:使用systembartint

compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
第二步:一行代码实现沉浸式状态栏

SystemBarUI.initSystemBar(this,R.color.red);
第三步:在activity资源文件根目录添加 android:fitsSystemWindows="true"属性,解决标题栏与状态栏重叠现象

xml version="1.0" encoding="utf-8"?>
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:orientation="vertical"
    android:fitsSystemWindows="true"
    tools:context="com.hope.tupian.MainActivity">

你可能感兴趣的:(Android基础)