我是开发混合应用程序的新手。我正在使用钛Js,并创建了一个视图。里面有列表和部分。我面临列表项相互重叠的问题。我已附上以下屏幕截图。请检查以下JSON格式的代码。
{
"caseInsensitiveSearch": true,
"separatorColor": "#C8C7CC",
"defaultItemTemplate": "listDefaultTemplate",
"canScroll": true,
"sectionCount": 0,
"sections": [],
"hiddenBehavior": 4,
"enabled": true,
"visible": true,
"touchEnabled": true,
"bottom": "55dip",
"top": "65dip",
"backgroundRepeat": false,
"keepScreenOn": false,
"children": [],
"size": {
"x": 0,
"width": 0,
"y": 0,
"height": 0
},
"rect": {
"width": 0,
"x": 0,
"y": 0,
"height": 0
},
"apiName": "Ti.UI.ListView",
"bubbleParent": true,
"soundEffectsEnabled": true,
"horizontalWrap": true }
列出部分代码:
{
"headerTitle": "Distance Units",
"footerTitle": null,
"items": [
{
"template": null,
"properties": {
"itemId": 1,
"color": "#000000",
"left": "7dip",
"accessoryType": 0,
"title": "Feet",
"font": {
"fontSize": "16dip"
},
"height": "55dip"
}
},
........
........
........
],
"footerView": null,
"headerView": null,
"keepScreenOn": false,
"children": [],
"size": {
"x": 0,
"width": 0,
"y": 0,
"height": 0
},
"rect": {
"width": 0,
"x": 0,
"y": 0,
"height": 0
},
"apiName": "Ti.UI.ListSection",
"bubbleParent": true
}
请帮助le找出解决方案。
以上问题的屏幕截图:
下次,请发布一些代码,而不是JSON输出。看看这个例子
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var myTemplate = {
childTemplates: [{
type: 'Ti.UI.Label',
bindId: 'info',
properties: {
color: 'black',
font: { fontFamily:'Arial', fontSize: 20, fontWeight:'bold' },
left: 60, top: 0,
}
}]
};
var listView = Ti.UI.createListView({
templates: { 'template': myTemplate },
defaultItemTemplate: 'template'
});
var sections = [];
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits / Frutas'});
var fruitDataSet = [
{ info: {text: 'Apple'}, properties: {height: 100,backgroundColor:"#f00"}},
{ info: {text: 'Banana'}, properties: {height: 50}},
{ info: {text: 'test'}, properties: {height: Ti.UI.SIZE,backgroundColor:"#f00"}}
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
listView.setSections(sections);
win.add(listView);
win.open();
将高度设置为3个不同的值(使用Ti.UI.SIZE
固定和可变)
在您的示例中,标签高度看起来不正确。因此,只需将其设置为Ti.UI.SIZE
。而且您不需要写dip
。除非您在tiapp.xml中删除/更改了它,否则它是默认单位。
然后Ti 7.4.0从2018年开始!您将无法使用此版本进行商店更新。您应该更新到最新版本(9.0.1.GA)或至少更新到8.3.x!