Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Force Label height to single row height

    Hi Devs,

    The label1 contain a DIV with two hidden row. I want to make the label1 to display as single row, same height with label2.
    May I know any function can force the height to single row?


    Click image for larger version

Name:	label_height.JPG
Views:	51
Size:	10.5 KB
ID:	251311

    Code:
            VLayout hLayout = new VLayout ();
            hLayout.setWidth100();
            hLayout.setHeight100();
    
            Label label1 = new Label ();
            label1.setContents("<div>First Label</div><div style=\"visibility: hidden;\">Hidden Row1<br/>Hidden Row2</div>");
            label1.setBorder("1px solid red");
            label1.setHeight(30);
    
            Label label2 = new Label ();
            label2.setContents("<div>Second Label</div>");
            label2.setBorder("1px solid red");
            label2.setHeight(30);
    
            hLayout.addMembers(label1, label2);

    #2
    It's not clear why you're using <div>s inside of a Label instead of simply using multiple components, or what you intend to do with the hidden content, so it's quite possible you've started down the wrong path entirely.

    However, as far as your current approach, the Label is going to autofit to the content you provide, including hidden content, because the browser reports sizes including such content. Using display:none instead of visibility:hidden would remove the content from the browser's reported sizes.

    Comment

    Working...
    X