为什么状态栏重新设置为红色

时间:2019-05-30 19:45:52

标签: android android-theme

因此,我设置了一些cosutome主题,其中一个将状态栏的颜色更改为黑色。但是,当片段加载时,它又变回红色,我无法一生找出原因。

清单:

<application
    android:name=".ApplicationImpl"
    android:allowBackup="false"
    android:fullBackupContent="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:resizeableActivity="true"
    android:theme="@style/Theme.Blue"
    tools:replace="android:allowBackup,android:fullBackupContent"
    tools:ignore="GoogleAppIndexingWarning"
    tools:targetApi="n">

<activity
   android:name=".auth.LoginActivity"
   android:label="@string/title_activity_srlogin"
   android:launchMode="singleInstance"
   android:theme="@style/Theme.SR.Light"
   android:windowSoftInputMode="adjustResize|stateHidden" />

LoginFragment:

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
    val contextThemeWrapper = ContextThemeWrapper(activity, R.style.Theme_SR_Light)
    val tempInflater = inflater.cloneInContext(contextThemeWrapper)
    return tempInflater.inflate(R.layout.fragment_login, container, false)
}

样式:

<style name="Theme.SR.Base.StatusBarBlack" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="android:statusBarColor">@color/sr_black</item>
</style>


<style name="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="Theme.SR.Base" parent="Theme.AppCompat.Light.NoActionBar">
</style>

<style name="Theme.SR" parent="Theme.SR.Red"/> 

<style name="Theme.SR.Red" parent="Theme.SR.Base">
    <item name="colorPrimary">@color/redPrimaryColor</item>
    <item name="colorPrimaryDark">@color/redPrimaryDarkColor</item>
    <item name="colorAccent">@color/redAccentColor</item>
</style>


<style name="Theme.SR.Blue" parent="Theme.SR.Base">
    <item name="colorPrimary">@color/bluePrimaryColor</item>
    <item name="colorPrimaryDark">@color/bluePrimaryDarkColor</item>
    <item name="colorAccent">@color/blueAccentColor</item>
</style>

   <style name="Theme.SR.Light" parent="Theme.SR.Base.StatusBarBlack">
    <item name="colorPrimary">@color/sr_red</item>
    <item name="colorPrimaryDark">@color/sr_red_status_bar</item>
    <item name="colorAccent">@color/sr_red</item>
</style>

我错了什么?

0 个答案:

没有答案