天天看点

android app 状态栏,Android 将App的内容延伸到状态栏/导航栏

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"

tools:context=".MainActivity"

android:orientation="vertical">

android:id="@+id/toolbar"

android:background="@color/colorAccent"

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="测试"

android:textColor="#000000"/>

代码中控制

View decorView = getWindow().getDecorView();

int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_STABLE;

decorView.setSystemUiVisibility(option);

getWindow().setStatusBarColor(Color.TRANSPARENT);

效果:(没有设置前状态栏(显示事件电量栏)是黑色背景,切与导航栏分开的,设置后效果如下图)

android app 状态栏,Android 将App的内容延伸到状态栏/导航栏

image.png