簡體   English   中英

鈦:標簽重疊問題

[英]Titanium : Label over lapping issue

對於Android

我在表格行中有兩個標簽。 我試圖將這兩個標簽設置為垂直,但是firstLabel與第二個標簽重疊。 由於firstLabel的高度為“ 自動 ”,因此包含動態文本,例如10行,20行。

由於firstLabel動態高度,我無法設置secondLabel的頂部,因此會重疊。

我已經嘗試了SO和Appcelerator上所有可用的解決方案,但找不到解決方法。

1)。 在將它添加到視圖,表的行等之前或之后,我無法獲取firstLabel高度...

2)嘗試根據文本的長度設置標簽的高度,但無法修復。

仍在尋找解決方案。

在此處輸入圖片說明

您要做的不是在標簽上將布局設置為垂直,而是在包含所有標簽的視圖上將布局設置為垂直。 如果父視圖具有垂直布局,它將在第一個標簽結束后立即放置第二個標簽。 此外,設置第二個標簽的“ top”屬性會將許多單位放置在label1的底部和標簽2的頂部之間。考慮一下CSS中塊元素的相對位置。

解決了...根據DannyM的回答。 我還注意到,將標簽的順序添加到行中也很重要。

for (var i = 0; i < results.length; i++)
{
    // Create a row and set its height to auto
    row = Titanium.UI.createTableViewRow
    ({
        height:'auto',
        layout :'vertical'
    });

    var currentObj = results[i];
    // Create the label to hold the place name
    var placeNameLabel = Titanium.UI.createLabel
    ({
        text:currentObj.PlaceName,
        left:'75dp',
        top:'auto',
        width:'auto',
        height:'18dp',              
        textAlign:'left',
        font:{fontSize:'14dp',fontWeight:'bold'},
        wordWrap:true
    });

    var placeAddressLabel = Titanium.UI.createLabel
    ({
        text:currentObj.PlaceAddress,
        left:'75dp',
        top:'auto',
        width:'230dp',
        height:'auto',      
        textAlign:'left',
        font:{fontSize:'14dp'}                  
    });

    var checkInDate = Titanium.UI.createLabel
    ({
        text:currentObj.CheckInDate+' '+currentObj.CheckInTime,
        left:'75dp',
        top:'auto', //placeAddressLabel.height + 30 +'dp',
        width:'165dp',
        height:'25dp',
        textAlign:'left',
        font:{fontSize:'14dp'},
        wordWrap:true,
    });

    row.add(placeNameLabel);
    row.add(placeAddressLabel);
    row.add(checkInDate)

    tableData[i] = row;
 }
 return tableData ;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM