Dave
Dave

Reputation: 5416

Make view 20 less than platformWidth android titanium

I have a tableViewRow with a view inside it.

Trying to set the view to the platormWidth - 20, with a left of 10, so it's centered.

This works fine on iOS but not android (see green rectange in photo below):

enter image description here

Why?

var innerView = Ti.UI.createView({
    width: Ti.Platform.displayCaps.platformWidth - 20,
    height: 20,
    backgroundColor: 'green',       
    left: 10,
    top: 10,
    layout: 'horizontal'
}); 

Thanks.

Upvotes: 0

Views: 163

Answers (2)

Josiah Hester
Josiah Hester

Reputation: 6095

The default is to have the view centered, so just do this:

var innerView = Ti.UI.createView({
    width: Ti.Platform.displayCaps.platformWidth - 20,
    height: 20,
    backgroundColor: 'green'
}); 

Upvotes: 0

Muhammad Adnan
Muhammad Adnan

Reputation: 2668

var innerView = Ti.UI.createView({
    height: 20,
    backgroundColor: 'green',       
    left: 10,
    right:10,
    top: 10,
   // layout: 'horizontal'
}); 

Upvotes: 1

Related Questions