ビューの "center"プロパティ(たとえばラベル)を使用する方法をお聞きしたいと思います。私が設定した場合、何も起こりません。作成時にポイント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ウィンドウ= Ti.UI.createWindow作成({ 幅:幅、 高さ:高さ、 のbackgroundColorを "#1 FFFFFF" })。 は、事前定義された左パディング VARボタンでウィンドウにボタンを追加// = Ti.UI.createButton({ タイトル:20、 色:、 左の "私を押して" "#000000" を})。 window.add(button); button.addEventListener( "click"、function() { //ボタンの位置を中央に設定する必要がありますが、何もしません。 button.setCenter(width/2、height/2); }); window.open(); –