Changing label height property dynamically - html

I have a line of code:
Label11.Style["Height"] = (Label11.Height.Value + 15).ToString() + "px";
I populate the Label with text, each time I'm doing it I would like to increase the height of the Label by 15 px.
After the first populate it works fine (Height = 30), but after that it didn't change.
What am I doing wrong?

Finally, I managed to find the solution:
Label11.Height = new Unit((int)Label11.Height.Value + 15);

Related

Problem setting width in dynamically created textbox in vb.net

I use these lines to dynamically create buttons and text boxes.
For i As Integer = 1 To 100
Dim newButton = New Button()
newButton.Text = i
newButton.ID = i
newButton.CommandName = i
newButton.Style.Add("width", "20%")
newButton.Style.Add("height", "100%")
Panel1.Controls.Add(newButton)
Next
For i As Integer = 1 To 100
Dim newtext = New TextBox()
newtext.TextMode = TextBoxMode.MultiLine
newtext.Style.Add("width", "20%")
newtext.Style.Add("height", "100%")
Panel2.Controls.Add(newtext)
Next
While the buttons fit the page width correctly, text boxes leave a space to the right.
1 2
I've tried assigning a class instead of width, but it doesn't work.
"min-width" also doesn't work.
How to set the text boxes to fit the page width?
I resolved setting textbox border-width and padding to zero pixels.
newtext.Style.Add("border-width", "0px")
newtext.Style.Add("padding", "0px")

libgdx - scene2d.ui label position

How can I dock a multiline Label to the bottom of the screen? There's the Label.setY() method but it works in some arcane way that makes no sense to me. I can get the approximate height of the label with getWrappedBounds() but I can't figure out how to use the label's height to set the position of the label.
You cannot position directly a label, you would have to add to a class that is using WidgetGroup such as Table. Or you can a Container [that is supposed to be more lightweight than a Table] and add the label to it:
Label testLabel = new Label("testme",super.getSkin(),"gameName");
Container labelContainer = new Container(testLabel);
labelContainer.bottom();
Then the label should be displayed at the bottom
You should prepare your label first and then place it:
skorTextLabel = new Label("Score " + level_skoru, skorTextStyle);
skorTextLabel.setPosition(
ekran_genisligi * 0.5f - skorTextLabel.getWidth() * 0.5f,
skorTextLabel.getHeight() * 0.3f);
"skorTextLabel.getHeight() * 0.3f" distance from bottom.

Header using Itext

ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(headerContent,headerFont) ,document.right() - 300, document.top() + 5, 0);
I have this line of code.For A4 papersize I get the header at the center of the page but for A3,A2,A1 I get it to the left of the page.What should I do so that I get it to the center of the page for all papersize(A4,A3,A2,A1).
You should use (document.left() + document.right()) / 2 for the x value.
As for the y value, you should use document.top() - (headerFont.getSize() * 1.5f). As far as I know document.top() + 5 results in adding text in the invisible area above the actual page.

Issue with getting div height dynamically

I have been trying to get the height of an image dynamically while adjusting the browser window.
I used console.log() to get the value to check if my results are correct, and somehow the result is always 0! What am I doing wrong?
$(function(){
var ScreenHeight = $(window).height();
var ImageHeight = $('#bkgImages').height();
var ImageMove = (ScreenHeight-ImageHeight)/2
$('#wrapper').slideDown(500);
$('#bkgScreen').animate({opacity: .5}, 700);
$('#bkgImages').css({top: "-" + ImageMove + "px"});
console.log(ImageHeight);
});
I manage to get the window height result working but not the div element height. The other issue is this calculates the result only once per session, where as I need to function to run every-time a user adjusts the browser window size. How do I go about doing that?
I think it depends on the css property of the div, and you may refer to answer here https://stackoverflow.com/a/10656669/693110.
In short, you need to specify the div to have display: inline-block; property.

How to get a RadioButton's label height - AS3

I want to get radioButton's label height in as3.
I have 5 radio buttons in my radioButton group. One of those radioButtons has a three line label, another has a single line etc...
When I try to access the radioButton.height, I always get same value regardless of the label height.
I need to know the height of the label, so I can set the radioButton y coordinate accordingly.
can I change the radioButton's label height?
spacing = 30;
rb.label = tempQQString //from xml. long or short string anyone
rb.group = myGroup;
rb.value = i + 1;
rb.x = answerX;
rb.y = questionField.height + (questionY+20) + (i * spacing); // here use rb.height or rb.textField.height
trace("rb height**" + rb.height) // always get velue 22;
addChild(rb);
RadioButton and any fl control that extends labelButton (all the ones that have a label), expose the actual text field with the .textField property.
So for your example, instead of using rb.height, you would use rb.textField.height to get the height of just the label portion of the control.
You can also set properties on the textField as well.
rb.textField.background = true;
rb.textField.backgroundColor = 0xDDDDDD;
rb.textField.multiline = true;
rb.textField.wordWrap = true;
rb.textField.autoSize = TextFieldAutoSize.LEFT;
now, for your scenario, you may be better off just using the radio button's bounds instead, as it will be the REAL height of the object.
rb.getBounds(rb).height; //this will be the true height of the component.
If your label was one line and your icon was taller than your label, you could potentially be getting a value from rb.textField.height that is smaller than the real height of the radio button.
Try this.
for(var i=0;i<rb.numChildren;i++){
if(rb.getChildAt(i) is TextField){
var txt:TextField = rb.getChildAt(i) as TextField;
trace(txt.height+":"+rb.height);//traces the height of text field and radio button
}
}