javascript - Titanium ScrollView 无法正确显示 UI

标签 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,
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);



这是它显示的内容:http://imgur.com/t4AQTMJ

我不明白为什么所有东西都堆叠在一起。

有人可以指出我遗漏了什么吗?

谢谢。

最佳答案

有很多方法可以构建您想要的 UI。 首先,您将 sv( ScrollView )的所有子元素置于顶部。每个子元素都从 SV 起始位置开始。 如果你想给 sv 的每个子元素顶部,然后将布局垂直属性应用于 ScrollView 。

第二种方式是在第一个元素结束后给出顶部。

每个人都在 ScrollView 中排在最前面,所以他们都骑在每个人身上, 首先申请第一种方式,如果遇到任何困难,请告诉我。

不使用布局样式会给它一个类似于 HTML 的 position:absolute 的属性。 不使用布局有时很好,因为它有助于使 View 居中。

关于javascript - Titanium ScrollView 无法正确显示 UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26835124/

相关文章:

javascript - MVC 和钛,结构

javascript - 当饼图jqplot为100%时平方

javascript - 如何利用 jQuery 来检测带有动态生成的 ID 的选择标签上的变化并更改选择的选项

javascript - 如何使 HTML5 Canvas 图案 fillstyle 随绘制对象一起移动?

android - 修复 ScrollView 上的一个元素

ios - 键盘出现时如何滚动 UIScrollView?

Android:如何监听滚动事件?

android - 当其中的 View 触发 Android 中的事件时无法滚动 ScrollView

javascript - 如何编译 require 语句?

titanium - 桌面通知-Tide SDK