【问题标题】:Space between Each Tableviewrow Titanium Alloy每个 Tableviewrow 钛合金之间的空间
【发布时间】:2014-04-03 12:58:57
【问题描述】:

如何获取 TableViewRow 之间的空间如上图所示。

Window.js

for(var i=0;i < election.length ;i++){
//  
    tblRow_Election[i] = Titanium.UI.createTableViewRow({
        height:(Ti.Platform.osname == 'ipad')?'280':'140',
        width:Titanium.Platform.displayCaps.platformWidth,
        left:(Ti.Platform.osname == 'ipad')?'20':'10',
        right:(Ti.Platform.osname == 'ipad')?'20':'10',
        color:'red',
        touchEnabled: true, 
        borderRadius:'4',
        borderWidth:'1',
        borderColor:'green',

    }); 

        data.push(tblRow_Election[i]);
}

    $.tbl_ElectionList.data = data;

窗口.tss

"#tbl_ElectionList":{

    top:'40',
    height:'auto',
    backgroundColor:'transparent',
    left:'10',
    right:'10', 
    style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
    borderColor:'green',
    separatorInsets: {
      left:0,
      right:0,
  },
}

窗口.xml

<Alloy>
    <Window id="ElectionWin" class="ElectionWindow" >
        <View class="container" id = "view_Election" backgroundColor="white">
            <TableView id="tbl_ElectionList">
            </TableView>    
    </View>
    </Window>
</Alloy>

无法获得每行之间的间隙。谁能建议我如何实现每个 tableviewRow 之间的差距。

@提前致谢

【问题讨论】:

  • @Armand 跟IOS有关!但使用跨平台钛工作室和javascript。
  • 在那种情况下我很抱歉...你能重新设置标签,还是我需要这样做?
  • 没问题,我会编辑并重新标记。

标签: javascript ios titanium tableview titanium-alloy


【解决方案1】:

首先您必须设置separator style to none,以便您可以自己定义间隙,您可以在表格的tss中设置它,我也不会使用分组样式,因为这会进一步限制您的样式:

"#tbl_ElectionList":{
    top:'40',
    height:Ti.UI.SIZE,
    left:'10',
    right:'10', 
    separatorStyle : Titanium.UI.iPhone.TableViewSeparatorStyle.NONE,
    borderColor:'green'
}

尝试以这种方式添加行,您应该会看到间隙

var containerrow = Titanium.UI.createTableViewRow({
    height:(Ti.Platform.osname == 'ipad')?'280':'140',
    width: Ti.UI.FILL
}); 

// This innerView will be set in the middle of the row
// It will hold your main row content
// We make it smaller than the row to give padding
var innerView = Ti.UI.createView({
    width : '80%',
    height : '80%',
    color:'red',
    borderRadius:4,
    borderWidth:1,
    borderColor:'green'
 });
 containerrow.add(innerView);
 // Add to the table data
 data.push(containerrow);

然后当然要像以前一样设置数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多