Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

createView problems!

I have a problem with my view. this is my code:

var barV = Titanium.UI.createView({
   borderRadius:0,
   backgroundImage:'images/bar.png',
   width:Titanium.Platform.displayCaps.platformHeight,
   height:44,
   top:0
});
mainW.add(barV);

In this view i try to create a button:

var topB = Ti.UI.createButton({
    width:23, height:24,
    top:10, right:10,
    backgroundImage:'images/topB.png',
    color:'#FFFFFF'
});
barV.add(topB);

But i want the view to have the width of the screen, so thats its full in both portrait and landscape. But when i just set width to the platform.Height the button ain't placing correct. How can i set it to scale the background, so the button allways stays in the right side, 10 px away from the side?

Please tell me if it's not understandable.

— asked December 2nd 2010 by Søren Fritzbøger
  • android
  • iphone
  • mobile
  • view
0 Comments

2 Answers

  • What do you want to position 10px from the right? the button? or the background?

    If the button try this:

    barV.width = '100%'
    
    — answered December 2nd 2010 by Dan Tamas
    permalink
    1 Comment
    • I want the button to be placed 10px from the right. On iphone '100%' works fine but on android it creates a bar that is around 100px wide, and centered. The button is placed correct but the width of the view is only filling up something around 33.33% of the entire screen.

      — commented December 2nd 2010 by Søren Fritzbøger
  • sorry nvm.

    — answered December 2nd 2010 by Søren Fritzbøger
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.