2013-03-15 3 views
-2

나는 tablerow에 하루의 이름으로 레이블을 갖고 싶습니다. 이것은 레이블의 실제 폭을 알지 못한다는 것을 의미하며, label.toImage(). width는 postlayout 이벤트 후에도 실제 크기를 반환하지 않습니다. 또한 가로 스크롤 막대를 임의의 텍스트 (때로는 매우 큰)와 나란히 정렬하려고합니다. 제가있는 것은 : 나 폭 설정하면티타늄 tablerow 내부 가로 레이아웃

var storehoursscrollingmessagestyle = { 
    left:"10dp", 
    font:{fontSize:'18dp',fontWeight:"bold"} 
}; 

var storehoursscrollviewstyle = { 
    contentWidth: 'auto', 
    contentHeight: 'auto', 
    height: '70dp', 
    width:Ti.UI.FILL, 
    scrollType: 'horizontal' 
}; 

var storehoursrowstylegray={ 
    classNane:"storeoptions", 
    selectedBackgroundColor:"#E8E8E8", 
    backgroundColor:"#E8E8E8", 
    height:"70dp"}; 

var storehoursrowlabelstyle={ 
    left:"10dp", 
    height:"70dp", 
    font:{fontSize:'18dp',fontWeight:"bold"}, 
    color:"Black" 
}; 

var storehoursviewrowstyle ={ 
    width:'200dp', 
    height:'70dp', 
    layout:'horizontal' 
}; 


var storehoursbuttontitleview = Titanium.UI.createLabel(storehoursrowlabelstyle); 
storehoursbuttontitleview.text = dayMappings[today] + " " + openTimeFormatted + " - " + closeTimeFormatted; 
storehoursbuttonview.add(storehoursbuttontitleview); 


var view = Ti.UI.createView(storehoursviewrowstyle); 

var scrollview = Ti.UI.createScrollView(storehoursscrollviewstyle); 
scrollview.add(storehoursscrollingmessagetitleview); 
view.add(storehoursbuttontitleview); 

var subviewviewforscrollview = Ti.UI.createView(storehoursviewrowstyle); 
subviewviewforscrollview.add(scrollview); 
view.add(subviewviewforscrollview); 
storehoursbuttonview.add(view); 

는 : 수평 레이아웃은 예상대로이지만 경우 도시 될 것이다 storehoursscrollviewstyle 위해 '30 %의 '를 난 스크롤 뷰 사라지고 100 %로 설정.

그래서 내 질문은 테이블 행 내부에 레이블 및 스크롤링 뷰를 가지며 크기를 알지 못하고 서로 하드 코드 된 너비 값을 설정하지 않습니다.

+0

pls 실제로 표시하고 싶은 이미지를 배치하십시오. 혼란스럽고 큰 변수가있는 코드는 높이가 고정되어 있기 때문에 –

+0

을 이해하지 못할 수도 있습니다 ... 왜 테이블 뷰를 사용하지 않습니까? TableViewRow에 뷰를 추가하면 실제로 원하는 것을 할 수 있습니다. –

답변

0

내 레이블에 postlayout 이벤트를 추가하고보기 및 하드 코드 된 너비에서 가로 레이아웃을 제거했습니다.

function storehoursbuttontitleview_postlayout(e) { 
if (e.source.set == null) { 
    var storehoursscrollingmessagetitleview = Titanium.UI.createLabel(storehoursscrollingmessagestyle); 
    storehoursscrollingmessagetitleview.text = e.source.closedMessage; 
    var view = Ti.UI.createView(storehoursviewrowstyle); 
    view.left = e.source.size.width + 20 + "dp"; 
    var scrollview = Ti.UI.createScrollView(storehoursscrollviewstyle); 
    view.add(scrollview); 
    if (Titanium.Platform.name != 'android') { 
     var str = e.source.closedMessage; 
     var chunks = []; 
     for (var i = 0, charsLength = str.length; i < charsLength; i += 100) { 
      chunks.push(str.substring(i, i + 100)); 
     } 
     var finalwidth = 0; 
     for (i=0; i<chunks.length; i++) { 
      var storehoursscrollingmessagetitleviewtemp = Titanium.UI.createLabel(storehoursscrollingmessagestyle); 
      storehoursscrollingmessagetitleviewtemp.text = chunks[i]; 
      finalwidth = finalwidth + storehoursscrollingmessagetitleviewtemp.toImage().width; 
     } 
     var labelInsideScrollWidth = finalwidth; 
     storehoursscrollingmessagetitleview.width = finalwidth + 10 + "dp"; 
     scrollview.add(storehoursscrollingmessagetitleview); 
    } 
    else { 
     scrollview.add(storehoursscrollingmessagetitleview); 
    } 
    e.source.row.add(view); 
    e.source.set = true; 
} 
}