[TIMOB-16816] Android: Cannot refer default splash screen image (default.png) for image view
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.2.2 |
Fix Version/s | n/a |
Components | Android |
Labels | android, bug, cb-tooling |
Reporter | Thijs van Mil |
Assignee | Chris Barber |
Created | 2014-04-02T11:02:45.000+0000 |
Updated | 2017-01-04T18:05:23.000+0000 |
Description
When trying to create an ImageView, you cannot use the splashscreen images (default.png) on Android. The usecase is a dynamic loading screen that is displayed while the app is starting up. This loading screen must have the splash image as the background so it looks like the default splash screen of the app.
Neither the standard default.png nor the density-specific images can be referenced to use as background for the window or image parameter for an ImageView.
The warning in the console is:
[WARN] : TiDrawableReference: (pool-3-thread-1) [1889,1889] Could not open stream to get bitmap
A workaround is to duplicate every default.png in every folder, and rename it to something else (default2.png or test.png for instance). Then it does find the resource.
Testcase:
var win = Ti.UI.createWindow({
backgroundColor : '#ffffff',
navBarHidden : true,
exitOnClose : true
});
var view = Ti.UI.createView({ backgroundColor: "#fdd" });
var imgView = Ti.UI.createImageView({
image: '/images/default.png',
width: 150,
height: 150
});
view.add(imgView);
win.add(view);
win.open();
Moving this ticket to engineering as I can reproduce this issue with the provided test case. Same test works fine on iOS platform.
While not an appropriate solution to this problem, because of how resources are looked up you can use:
Ti.App.Android.R.drawable.background
to access the splash. While not the best, in the meantime this is a solution.Issue reproduces Titanium SDK version 3.4.0 master, 3.3.0.GA, 3.2.3.GA, 3.2.2.GA Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4
This behavior has been around a long time and it is by design (and not the good kind). We have discussed a Titanium Asset Management system that will separate out system managed resources (such as splash screens) from Titanium controlled assets (i.e. Resources/images). View TIMOB-19298 for more information.