我正在尝试获取操作栏的高度(以像素或DIPS为单位)。 我只能返回0;
<Page class="page"
navigatingFrom="onNavigatingFrom"
navigatingTo="onNavigatingTo"
xmlns="http://schemas.nativescript.org/tns.xsd">
<ActionBar id="actionBar" class="action-bar theme-action-bar">
function onNavigatingTo(args) {
var actionBar = page.getViewById("actionBar");
var height = actionBar.getActualSize().height;
//or
var height = actionBar.height;
}
答案 0 :(得分:0)
尝试添加超时,
function onNavigatingTo(args) {
var actionBar = page.getViewById("actionBar");
setTimeout(()=>{
var height = actionBar.getActualSize().height;
}, 100);
}