How can I change android: windowBackground?

So, I'm trying to use a special theme for my Android application with unity, the idea is to change the color (or even add an image) while the application is loading (before the unity logo), as some lower devices take up to 10 seconds to show a splash and a 10 second black screen just makes it look like the application is broken.

So far, my Android manifest has:

android:theme="@style/CustomTheme"

I have another stylesheet file:

<resources>
    <style name="CustomTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
        <item name="android:windowBackground">@drawable/editor_bg</item>
    </style>
</resources>

Whenever I change the parent style I say Theme.Translucent.NoTitleBar, I see the change, my application removes the black screen, so I know the style. It has been modified / used.

My problem is that @ drawable / editor_bg doesn't work at all, I even tried to use color instead of the image with @ color / white defined in another file.

Not sure if this is a problem with unity itself (using version 5.3.1) or the lack of something on the Android side. Any help is appreciated.

+4
source share
3 answers

Try the following:

<resources> 
<style name="CustomTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen"> 
<item name="android:windowBackground">@drawable/editor_bg</item>
<item name="?windowBackground">@drawable/editor_bg</item>  
</style> 
</resources>
0
source

Try installing it programmatically:

getWindow().setBackgroundDrawableResource(R.drawable.editor_bg);
0
source

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2_r1/com/android/internal/policy/impl/PhoneWindow.java#2834

mBackgroundResource = a.getResourceId(
com.android.internal.R.styleable.Window_windowBackground, 0);

mDecor.setWindowBackground(drawable);

public void setWindowBackground(Drawable drawable) {
    if (getBackground() != drawable) {
        setBackgroundDrawable(drawable);
0
source

Source: https://habr.com/ru/post/1625145/


All Articles