1

I have added a custom theme with background image to serve as "splash" image to make the app look nicer while unity player is loading.

That's the theme definition I have

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Test" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
    <item name="android:windowBackground">@drawable/launchimage</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>
</resources>

Now, when I refer to this theme in AndroidManifest.xml like:

<activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/Theme.Test" ... ></activity>

the game just "freezes" – it's hard to tell in fact, because it just displays the splash image and ... that's it. Logcat doesn't show any warnings/errors either.

Removing the theme OR changing android:windowBackground property to a solid color make the game work, but window background appears black until the game is launched.

What is the correct way to set activity background to make Unity happy?

Anton
  • 2,483
  • 2
  • 23
  • 35

1 Answers1

1

When your image is too large this issue happen. change your image with smaller and set centerCrop attribute may fixed this issue. (usually this show skip frame in your log)

Also if you use Android studio 2.0 there is newly issue with that you can find it here.

Community
  • 1
  • 1
Amir
  • 16,067
  • 10
  • 80
  • 119
  • The size indeed appeared to be the issue. However, it's still strange: the background (being a valid 9 patch image) doesn't stretch as it should and activity content gets squeezed into a tiny block in the middle of the screen. Why would background drawable affect content size at all?.. – Anton May 25 '16 at 07:20
  • in short: Android has some constraint about bitmap loaded into imageView because of memory limitation. – Amir May 25 '16 at 07:28
  • The thread doesn't seem to be relevant – I have already resized the image, and I don't see any OutOfMemory errors – Anton May 25 '16 at 07:28
  • I mean the image is really small (640x300, testing on SGS III) – it seems to be the layout that gets broken – Anton May 25 '16 at 07:29
  • Yeah, it doesn't throw any exception But in low memory devices does. take a look at [this](https://www.bignerdranch.com/blog/splash-screens-the-right-way/) and [this](http://stackoverflow.com/a/8205044/1462770) – Amir May 25 '16 at 07:33