Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 视图未正确显示用户界面_Javascript_Scrollview_Titanium Mobile - Fatal编程技术网

Javascript 视图未正确显示用户界面

Javascript 视图未正确显示用户界面,javascript,scrollview,titanium-mobile,Javascript,Scrollview,Titanium Mobile,这是我的代码: var startWeekWin = Ti.UI.createWindow({ title:'Startup Weekend', layout: 'vertical', backgroundColor:'#b6e2e2' }); // create scroll view here var sv = Ti.UI.createScrollView({ contentWidth:'auto', contentHeight: 'auto', top: 0, showVerticalS

这是我的代码:

var startWeekWin = Ti.UI.createWindow({
title:'Startup Weekend',
layout: 'vertical',
backgroundColor:'#b6e2e2'
});

// create scroll view here
var sv = Ti.UI.createScrollView({
contentWidth:'auto',
contentHeight: 'auto',
top: 0,
showVerticalScrollIndicator: true
}); 

startWeekWin.add(sv);

var lblPicture = Ti.UI.createLabel({
top: 0,
width: 'fill',
height: 100,
backgroundImage: 'images/StartUpWeekend.png'
});

var lblTitle = Ti.UI.createLabel({
top: 15,
left: 15,
right: 15,
height: '15%',
font: {
    fontSize: 24,
    fontWeight: "bold",
    fontFamily: "Helvetica"
},
text: "What is it?",
color: '#0a3f56',
backgroundColor: '#b6e2e2'
});

var lblText = Ti.UI.createLabel({
top: 30,
left: 15,
right: 15,
height: 70,
font: {
    fontSize: 16,
    fontFamily: "Helvetica",
},
text: "Etsy doostang zoodles disqus groupon " +
         "greplin oooj voxy " +
         "zoodles, weebly ning heekya " +
         "handango imeem plugg",
color: '#1d1d1d',
backgroundColor: '#b6e2e2'
});

var lblDate = Ti.UI.createLabel({
top: 30,
width: 'fill',
height: 50,
font: {
    fontSize: 24,
    fontWeight: "normal",
    fontFamily: "Helvetica",
    fontStyle: "italic"
},
text: "     January 23-25, 2015",
color: '#0a3f56',
backgroundColor: '#b6e2e2'
});

// video trailer goes here
var trailer = Ti.UI.createLabel({
top: 35,
width: 'fill',
height: 50,
text: 'Trailer Goes Here',
color: '#1d1d1d',
backgroundColor: '#b6e2e2'
});

// learn more button
var learnMoreButton = Ti.UI.createButton({
top: 40,
left: 40,
right: 40,
width: 180,
height: 50,
title: 'Learn More',
font: {
    fontSize: 18,
    fontFamily: "Helvetica",
    fontWeight: "normal"
},
color: '#0a3f56',
backgroundColor: 'white'
});

sv.add(lblPicture);
sv.add(lblTitle);
sv.add(lblText); 
sv.add(lblDate);
sv.add(trailer);
sv.add(learnMoreButton);

这就是它显示的内容: 我不明白为什么所有的东西都堆在一起。 有人能指出我遗漏了什么吗?
谢谢。问题在于你给每个元素的顶部。因为所有的元素都有顶部,而顶部会覆盖其他元素。如果您要更新顶部,您的布局将得到修复。

有许多方法可以构建您想要的UI。 首先,您将sv(滚动视图)的所有子元素指定给顶部。每个子元素从SV开始位置取顶部。 如果要为sv的每个子元素指定顶部,请将布局垂直属性应用于滚动视图

第二种方法是在第一个元素结束后给出top

每个人都从卷轴视图中取顶,所以他们都骑在每个人身上, 先用第一种方法,如果在这方面遇到任何困难,请告诉我

不使用布局样式会给它一个类似位置的属性:绝对的HTML。 不使用布局有时很好,因为它有助于将视图居中

非常感谢你!!“layout:'vertical'”属性是scrollview窗口中缺少的内容。它现在工作得很好:))