Reproduce
1. Run the following code on Both iOS and Android devices
var OS_IOS = (Ti.Platform.name === 'iPhone OS');
var locationBlockWindow = Ti.UI.createWindow({
backgroundColor:"#E6ffffff"
});
var transView = Ti.UI.createView({
top:Ti.Platform.displayCaps.platformHeight/(OS_IOS ? 3 : 6),
bottom:Ti.Platform.displayCaps.platformHeight/(OS_IOS ? 3 : 6),
left:40,
right:40,
layout:"vertical",
width:Ti.UI.FILL,
height:Ti.UI.FILL,
backgroundColor:"#80E7832B",
borderRadius: 5
});
var labelTxt = Ti.UI.createLabel({
font: { fontSize:'18dp' },
text: 'IAS Dispatch app is disabled while driving for your safety. Please use the app when vehicle is not in motion.',
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
center: {
x:0,
//y:100
y:Ti.Platform.displayCaps.platformHeight/(OS_IOS ? 6 : 24),
},
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
left: 10,
right: 10,
});
transView.add(labelTxt);
locationBlockWindow.add(transView);
locationBlockWindow.open();
Ti.API.info('Top: ' + transView.getTop());
Ti.API.info('Center: ' + labelTxt.getCenter().y);
Problem
In labelTxt the:
center: {
x:0,
y:Ti.Platform.displayCaps.platformHeight/(OS_IOS ? 6 : 24),
},
works in iOS but in Android. The "Ti.API.info('Center: ' + labelTxt.getCenter().y);" returns a valid number but we see no impact on the positioning of the label on Android.
[~sliang] Firstly, in the example given both
top
andbottom
are set to the same value, making the view invisible. Secondly,center
will not work on components added to a view with alayout
type defined.!test.png|thumbnail!
[~gmathews] Please confirm the last comment.
[~sliang] Correct, I'm not sure why you would define the exact position of a View if you're using a layout to determine the positioning?
Closing as invalid. Please reopen if you disagree [~sliang]