【问题标题】:Labels in TableViewRow cut off (Titanium Studio)TableViewRow 中的标签被切断(Titanium Studio)
【发布时间】:2014-07-15 04:55:12
【问题描述】:

我在让 TableView 中的标签正确显示时遇到问题,希望有人能提供帮助。

这里是问题的截图:

后面带有 (...) 的标签被切断。 当我为行设置固定高度时不会出现此问题,但由于文本的长度不同,这对我来说不是一个好的解决方案。

我尝试了this question 中的答案,但无济于事。

这是我生成表格的代码:

var aSection = Ti.UI.createTableViewSection({
    rows: [],
    headerView: header
});

for (var p = 0; p < answers.length; p++){
  var currentAnswer = answers[p]; 

  var arow = Ti.UI.createTableViewRow({
    selectedBackgroundColor:'#f5f5f5',
    answID: currentAnswer['aId'],
    map: currentAnswer['aMap'],
    isSelected: false,
    height: 'auto',
    rightImage: '/images/icons/radio-unselected.png'
  });

var atext = Ti.UI.createLabel({
    font:{fontSize:gui.defaultFontSize+2, fontFamily: gui.defaultFont},
    color: '#333',
    text: currentAnswer['aText'],
    left:10, top: 10, bottom: 10, right: 10,
    width:'auto',
    height: 'auto',
    borderWidth: 0,
    borderColor: "#000",
  });

  arow.add(atext);
  aSection.add(arow);
}

var sections = [];
sections[0] = aSection;

var answView = Ti.UI.createTableView({
  backgroundColor:'white',
  data: sections,
  bottom: 1,
  minRowHeight: 40,
});

我真的很茫然。任何指针表示赞赏。

【问题讨论】:

    标签: ios titanium tableview titanium-mobile


    【解决方案1】:

    尝试使用:minimumFontSize:'18sp'

    或一些适合您的显示需求的尺寸。这会将字体缩小到最小尺寸以适合所有内容。

    【讨论】:

      【解决方案2】:

      如果您的文本太长,则它与右侧按钮重叠,但您仍想显示全文,那么您应该设置左右或将宽度设置为 Ti.UI.SIZE 所以如果您想重叠右侧按钮,那么您是否应该使用 Ti.UI.SIZE 然后您可以设置左右

      简而言之,将宽度设置为 Ti.UI.SIZE 或设置左右属性。

      【讨论】:

        【解决方案3】:

        heightwidth 使用Ti.UI.SIZE 而不是autoauto 很久以前就被弃用了。这样的事情会帮助你

        var aSection = Ti.UI.createTableViewSection({
            rows: [],
            headerView: header
        });
        
        for (var p = 0; p < answers.length; p++){
          var currentAnswer = answers[p]; 
        
          var arow = Ti.UI.createTableViewRow({
            selectedBackgroundColor:'#f5f5f5',
            answID: currentAnswer['aId'],
            map: currentAnswer['aMap'],
            isSelected: false,
            height:Ti.UI.SIZE,
            rightImage: '/images/icons/radio-unselected.png'
          });
        
        var atext = Ti.UI.createLabel({
            font:{fontSize:gui.defaultFontSize+2, fontFamily: gui.defaultFont},
            color: '#333',
            text: currentAnswer['aText'],
            left:10,  right: 10,
            width:Ti.UI.SIZE,
            height:Ti.UI.SIZE,
            borderWidth: 0,
            borderColor: "#000",
          });
        
          arow.add(atext);
          aSection.add(arow);
        }
        
        var sections = [];
        sections[0] = aSection;
        
        var answView = Ti.UI.createTableView({
          backgroundColor:'white',
          data: sections,
          bottom: 1,
          minRowHeight: 40,
        });
        

        【讨论】:

        • 我这样做了,虽然它是一种改进(文本现在有换行符),但它仍然在某些地方被截断。
        • 你是否也将行大小设置为 Ti.UI.SIZE?
        • 它在删除标签上的“宽度”属性后工作。谢谢!
        猜你喜欢
        • 1970-01-01
        • 2018-11-07
        • 1970-01-01
        • 1970-01-01
        • 2012-12-05
        • 1970-01-01
        • 2017-02-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多