【问题标题】:TableView not showing in android titanium appceleratorTableView 未在 android 钛应用加速器中显示
【发布时间】:2015-10-26 03:00:26
【问题描述】:

TableView 显示在 iOS 模拟器中...但它没有显示在 android 物理设备中... 它们运行相同的代码并且没有发生错误。

var row = Titanium.UI.createTableViewRow({
                width : Titanium.UI.FILL,
                height : "20%",
                left : 0,
                backgroundColor : "orange",
                separatorColor : "transparent",
                fav_id:id,
            });

        var lblTitle = Ti.UI.createLabel({
            top : "5%",
            left : "0%",
            height : Titanium.UI.SIZE,
            width : "90%",
            text : title,
            textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT,
            color : "black",
            //backgroundColor : 'blue',
            maxLines: 2,
            touchEnabled : false
        });

        var lblDate = Ti.UI.createLabel({
            top : "50%",
            left : "0%",
            height : Titanium.UI.SIZE,
            width : "90%",
            text : date,
            textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT,
            color : "black",
            //backgroundColor : 'blue',
            //maxLines:1,
            touchEnabled : false
        });

        var lblCategory = Ti.UI.createLabel({
            top : "50%",
            left : "60%",
            height : Titanium.UI.SIZE,
            width : "90%",
            text : category,
            textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT,
            color : "black",
            touchEnabled : false
            //backgroundColor : 'white',
            //maxLines:1,
        });

        row.add(lblTitle);
        row.add(lblDate);
        row.add(lblCategory);
        dataTable.push(row);
$.tblFavourite.data = dataTable;

安卓系统怎么了?设计对tableview的输出有影响吗?

【问题讨论】:

  • 我认为问题出在height : "20%",
  • @Swan 并且高度是行高,不是整个 tableview 的高度...
  • @jefferyleo 尝试设置 row.height = "50dp"
  • 我认为在 tableView 行的情况下百分比不起作用。
  • @Surajkochale 天哪……你帮了我这个忙!谢谢,如何将您标记为正确答案?

标签: android ios titanium tableview appcelerator


【解决方案1】:

我认为在 tableViewRow 的情况下百分比不起作用。 尝试设置row.height = "50dp"
希望这会对你有所帮助。

【讨论】:

    【解决方案2】:

    正如 Suraj 已经指出的那样,在 Android 中不能使用百分比作为行高。但是我在the Appcelerator forums找到了一个解决方法:

    你应该自己计算你的百分比。使用Ti.Platform.displayCaps.platformWidthTi.Platform.displayCaps.platformHeight 进行计算。

    10% 高度示例:

    height : Math.floor(Ti.Platform.displayCaps.platformHeight / 10)
    

    【讨论】:

    • 这种方式我也可以做到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-07
    • 1970-01-01
    • 2017-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多