简体   繁体   English

Titanium ScrollView未正确显示UI

[英]Titanium ScrollView Not Displaying UI Properly

So this is my code: 所以这是我的代码:

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); sv.add(learnMoreButton);



And this is what it displays: http://imgur.com/t4AQTMJ 这就是它显示的内容: http//imgur.com/t4AQTMJ

I don't understand why everything is stacking on top of each other. 我不明白为什么一切都堆叠在一起。

Could someone point out what I'm missing? 有人能指出我错过了什么吗?

Thanks. 谢谢。

There is many way to build the UI That you want. 有很多方法可以构建您想要的UI。 First you given all child element of sv(scroll view) to top. 首先,您将sv(滚动视图)的所有子元素都放到顶部。 Every child element take top from the SV start position. 每个子元素都从SV起始位置开始。 If you want to give top to every child element of sv then apply layout vertical property to scroll view. 如果要为sv的每个子元素赋予顶部,则应用布局垂直属性以滚动视图。

And second way is give top after the end of first element. 第二种方式是在第一个元素结束后给出顶部。

every one is taking top from the scroll view so they all are over riding on every one, First apply first way and let me know if face any difficulty in this. 每个人都从滚动视图中取得顶部,所以他们都骑在每一个上,首先应用第一种方式让我知道如果遇到任何困难。

Not using layout style will give it a property similar position:absolute of HTML. 不使用布局样式会给它一个类似位置的属性:绝对的HTML。 Not using layout is at times good as it helps in centering the view. 不使用布局有时很好,因为它有助于使视图居中。

The Issue is with the top that you have given to every element. 问题是你给每个元素的顶部。 As all elements have top that is coming over other elements. 因为所有元素都有顶级元素。 If you will update the top your layout will be fixed. 如果您要更新顶部,您的布局将得到修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM