0
我想问你,如何使用视图的“中心”属性(例如标签)。如果我设置了它,没有任何反应,相应的标签将自己设置到屏幕的中心,无论我将其设置为点x和y.:20在创建时,但我需要稍后将其居中。重新定位标签
我的代码
var width = Ti.Platform.displayCaps.platformWidth;
var height = Ti.Platform.displayCaps.platformHeight; //create simple window
var window = Ti.UI.createWindow({
width:width,
height:height,
backgroundColor:"#ffffff"
});
//add button to window with predefined left padding
var button = Ti.UI.createButton({
title:"Press me",
left:20,
color:"#000000"
});
window.add(button);
button.addEventListener("click", function() {
//this should set button position to center, but does nothing
button.setCenter(width/2, height/2);
});
window.open();
你能用你的代码编辑你的文章吗?谢谢 – Giordano
var width = Ti.Platform.displayCaps.platformWidth; var height = Ti.Platform.displayCaps.platformHeight; //创建简单窗口 var window = Ti.UI.createWindow({ width:width, height:height, backgroundColor:“#ffffff” }); //添加按钮窗口与预定义的左填充 VAR键= Ti.UI.createButton({ 标题: “按我”, 左:20, 颜色: “#000000” }); window.add(button); button.addEventListener(“click”,function() { // this should set button position to center,but nothing nothing button.setCenter(width/2,height/2); }); window.open(); –