LWUIT Form.show() has a weird margin (or padding) - lwuit

When i add a Form to LWUIT using form.show(), the form is not set exactly in the (0,0) coordinate, it's leaving like 20 pixels in the top and 3 on the left.
I'm developing for the Nokia SDK 1.1 FYI and i'm using their version of LWUIT
Let me know if there is a workaround on this.
Cheers!
Alberto
EDIT:
Here is how i'm creating the Form
Display.init(this);
this.view = new Form();
this.view.setLayout(new CoordinateLayout(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()));
this.view.setScrollableY(false);
this.view.show();
This shows a padding on the top and on the left side (Bigger on the top than on the left side)
See a screen shot:

Found the 2 Issues:
1) I had to set the titleArea padding and margins to 0 like this:
this.view.getTitleArea().getStyle().setMargin(0, 0, 0, 0);
this.view.getTitleArea().getStyle().setPadding(0, 0, 0, 0);
this.view.revalidate();
2) For the left padding, it was in the label where i was placing the photo, so just changing it's style (padding) to 0 made the trick
Cheers,

Related

2D Unity: expand UI element based on text to the bottom

I've got a game object (InfoBox) with a..
Vertical Layout Group (Padding 20 on all sides, Control Child Size Height active)
an image
a Content Size Fitter (Vertical Fit set to Preferred Size, Horizontal Unconstrained)
Inside this InfoBox is a Text-Element and every time I update the text, I want the InfoBox to expand or collapse, but to the bottom only. Right now my InfoBox always expands or collapses to both top and bottom, but I don't want that to happen. How can I achieve that? I added some screenshots to better visualise this.
These are my settings for the InfoBox:
And these are my settings for the text:
And this is what happens when I use for example less text, the box collapses from bottom and top, but I want it to stay fixed at the top (on the same line as the green box next to it) and only collapse on the bottom:
Any help is really appreciate!
You main issues looks like you are using a ContentSizeFitter also on the parent object. So it depends how this parent object is aligned with its according parent.
This sentence sounds strange I know but what you did is basically shifting up the alignment responsibility to the parent.
=> Make your UI element aligned to the top and grow downwards.
All you need to do for this is either set
Anchors Min y -> 1
Anchors Max y -> 1
Pivot y -> 1
or simply go to the RectTransform Inspector, open the alignment tool and hold Shift + Alt and click on the top alignment:
For the second instead of using the ContentSizeFitter I prefer to have my own script that only does what it should and nothing more.
You can get the preferredHeight which is exactly the value you are looking for.
The following script simply always applies the preferred height to the text rect. Using [ExecuteAlways] this also works in edit mode. Simply attach it on the same GameObject as the UI.Text component
[ExecuteAlways]
[RequireComponent(typeof(Text))]
[RequireComponent(typeof(RectTransform))]
public class TextHeightFitter : MonoBehaviour
{
[SerializeField] private RectTransform _rectTransform;
[SerializeField] private Text _text;
private void Update()
{
if (!_text) _text = GetComponent<Text>();
if (!_rectTransform) _rectTransform = GetComponent<RectTransform>();
var desiredHeight = _text.preferredHeight;
var size = _rectTransform.sizeDelta;
size.y = desiredHeight;
_rectTransform.sizeDelta = size;
}
}

How to use the full width when an UI element is invisible in iphone?

I have a label and a button like in the above picture. I like the label to use full width when I click on hide button.
I tried setting the width to 0, how ever it does not change the label with. Is this correct? or is there a better way to do this ?
blockingButton.frame = CGRectMake(blockingButton.frame.origin.x, blockingButton.frame.origin.y, 0, blockingButton.frame.height)
No, 0 can cause problems.
Try this:
blockingButton.frame = CGRectMake(blockingButton.frame.origin.x, blockingButton.frame.origin.y, self.view.frame.size.width, blockingButton.frame.height)

How to display text in center if use verticalText?

My code
VerticalText vt = new VerticalText(writer.getDirectContent());
vt.setVerticalLayout(marginLeft + squareHeight, 1191.0f - marginTop, squareHeight, 3, 20);
vt.setAlignment(Element.ALIGN_CENTER);
Paragraph p = new Paragraph(imgr.getText(), fontV);
p.setLeading(10);
vt.addText(p);
vt.go();
The result : Text is middle in vertical mode.
I want to display text is center in horizontal mode as below link:
How to solve this problem ?
As documented, left, center and right align has a different meaning in the context of VerticalText. Left is top, center is middle and right is bottom.
With class VerticalText, you always write from right to left. There is currently no way to align the text as shown in the screen shot to the right.
However, you could work around this problem by adding the vertical text in simulation mode first and then calculate the number of lines that have been written.
See for instance the VerticalText1 example from my book. I have adapted the code of that example like this:
BaseFont bf = BaseFont.createFont(
"KozMinPro-Regular", "UniJIS-UCS2-V", BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 20);
VerticalText vt = new VerticalText(writer.getDirectContent());
vt.setVerticalLayout(390, 570, 540, 12, 30);
vt.addText(new Chunk(MOVIE, font));
vt.go();
System.out.println(vt.getMaxLines());
vt.addText(new Phrase(TEXT1, font));
vt.go();
System.out.println(vt.getMaxLines());
vt.setAlignment(Element.ALIGN_RIGHT);
vt.addText(new Phrase(TEXT2, font));
vt.go();
System.out.println(vt.getMaxLines());
The output of the System.out calls is:
11
4
1
These numbers are the number of lines that are available after each go().
We start with 12 lines as defined in the setVerticalLayout() method.
We add MOVIE and there are 11 lines left. We've defined a leading of 30, which means we've already consumed (12 - 11) x 30pt = 30pt.
Then we add TEXT1 which is distributed over 7 lines, which take 7 * 30pt in width. In total we now have consumed (12 - 4) x 30pt = 240pt.
Finally we add TEXT2 which is distributed over 3 lines. Only 1 line is left. The total horizontal width of all the text is 330pt (we had only 30pt left).
Now that you know this math, you can execute the go() method in simulation mode, calculate the width that was consumed and use that info to add your text for real at the desired position.

how to increase the default size of HeaderButton in MGWT

I want to increase the default size of HeaderButton Widget in MGWt.I tried this:
headerBackButton.setHeight(String.valueOf(50)+"px");
headerBackButton.setWidth(String.valueOf(50)+"px");
headerBackButton.getElement().getStyle().setWidth(50, Unit.PX);
headerBackButton.getElement().getStyle().setHeight(50, Unit.PX);
I have just tried in the mgwt.showcase (class UIViewImpl) and using the headerBackButton.setWidth("75px"); works perfect (just after headerBackButton = new HeaderButton(); ).
Have you checked you do not have other elements or other cssĀ“rules that block the resize??
For example, in the mgwt showcase after 80px the button does not get bigger because the p child element has the rule max-height

vb6 Inner Form Resize

Are it's possible to resize vb6 inner form, because if i use Form1.Height or Form1.Width it's including window border height and width, so i just can use this code in one window theme (ex. it's work best in WinXP with XP theme, but not work in WinXP with Classic theme, it's seen too long), any suggestion?
What you can do is compare the Width (the outside size) to the ScaleWidth (which is the inside size) to get the size on the non-client border. Likewise, you can compare the Height to the ScaleHeight to get the non-client size at the top and bottom. From that you can set your final height and width based on the inner (client area) size you want plus the non-client size.
Something like this could go in your Form_Load:
Const DesiredClientHeight as Single = 3435
Const DesiredClientWidth as Single = 3345
Dim fNonClientHoriz As Single, fNonClientVert As Single
fNonClientHoriz = Me.Width - Me.ScaleWidth
fNonClientVert = Me.Height- Me.ScaleHeight
Me.Width = DesiredClientWidth + fNonClientHoriz
Me.Height = DesiredClientHeight + fNonClientVert
Be aware that the form width and height are always in Twips, so if you change your scale mode to something other than twips you will need to account for that.