简体   繁体   中英

Appcelerator show an image

Greetings,

I'm trying to simply display an image using Appcelerator on Android.

I don't understand why it won't work.

Here is my code:

var back=Titanium.UI.createImageView({
 url:'images/back.png'
});

win.add(back);

I've also tried putting the image inside a view:

var view = Titanium.UI.createView({
   borderRadius:10,
   backgroundColor:'red',
   left:10,
     right:10
});
var back=Titanium.UI.createImageView({
 url:'images/back.png'
});
view.add(back);
win.add(view);

I'm totally stuck and am hoping someone can point me in the right direction here.

Many thanks in advance,

I got it working as follows:

var back_fn=Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'images/back.png');
var back=Titanium.UI.createImageView({
    image:back_fn,
    top:10,
    right:10
});
win.add(back);

Thanks for all the responses guys,

try this

var back=Titanium.UI.createImageView({
  url:'images/back.png',
  height : 130,
  width : 130
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM