Android活动主题位于导航和状态栏后面

时间:2018-10-09 22:02:43

标签: android splash-screen

为了创建一个简单的启动主题,我创建了一个如下的图层列表

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
    <item android:drawable="@color/colorAccent"/>
    <item>
        <bitmap
            android:src="@mipmap/test_mipmap"
            android:gravity="top"
            android:scaleType="center"/>
    </item>
</layer-list>

并使用该样式创建样式:

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/background_splash</item>
    </style>

然后将这种样式用作AndroidManifest中的Application主题

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/SplashTheme"> ... </application>

运行该应用程序时,我注意到初始屏幕有些全屏,并且状态栏和导航栏都显示在它的前面。但是,一旦加载了主布局,它将显示在导航栏和状态栏之间。

这是屏幕截图:

splash screen

上面,清楚地显示出状态栏后面的蓝色圆圈!

如果我按如下方式创建活动布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    tools:context=".MainActivity"
    android:background="@drawable/background_splash"> ... </android.support.constraint.ConstraintLayout>

并放置与布局背景相同的可绘制对象,圆会显示在正确的位置! (从我的角度来看)

enter image description here

我想要的是使启动主题的大小与布局相同。几乎忘了提及我正在使用minSdkVersion 16版

0 个答案:

没有答案