Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18307] Android: backgroundImage doesn't load application resources

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
LabelsTi.App.Android.R, drawable
ReporterFokke Zandbergen
AssigneeUnknown
Created2015-01-05T20:00:06.000+0000
Updated2018-02-28T19:54:54.000+0000

Description

The attached test project shows that an image in the application resources *can* be used as an image, but not as a backgroundImage.

Problem

The first View will not display the 9-patch image located in platform/android/res; this is the actual problem. The second ImageView *will* display the image in platform/android/res, but since it 9-patch is only supported for backgrounds it is stretched. The third View displays the same 9-patch image in Resources/images as expected.

Use case

What I wan to do is re-use the launch image as a background later in the app. Of course I can keep additional copies for all densities in but this increases the size of the app largely.

Code from the attached project

var win = Ti.UI.createWindow();

win.add(Ti.UI.createView({
  top: 0,
  left: 0,

  width: '33%',
  height: Ti.UI.FILL,

  backgroundColor: 'red',
  backgroundImage: Ti.App.Android.R.drawable.drawablenine
}));

win.add(Ti.UI.createImageView({
  top: 0,
  left: '33%',

  width: '34%',
  height: Ti.UI.FILL,

  backgroundColor: 'green',
  image: Ti.App.Android.R.drawable.drawablenine
}));

win.add(Ti.UI.createView({
  top: 0,
  right: 0,

  width: '33%',
  height: Ti.UI.FILL,

  backgroundColor: 'blue',
  backgroundImage: '/images/resourcesnine.png'
}));

win.open();

Attachments

FileDateSize
android_20150105-212740.png2015-01-05T20:27:54.000+0000104798
bg.zip2015-01-05T20:28:15.000+000045811

Comments

No comments

JSON Source