textfield - size or width

2 messages - 70 views

i try to search from the forum but there is no thread for this case. my xml file likes :

<screen title="helloworld">
    <container style="layout:inlinelayout(false,fill);align:center">
        <text>Người dùng</text>
                <textfield id="txtUser" constraints="text" ></textfield>
            <text>Mật khẩu</text>
                <textfield id="txtPass" constraints="password"></textfield>   
                <button style="layout-data:sld(width:15)">Login</button>
    </container>


</screen>

i wanna set the width of textfile and the "text","textfield" in the same line ..plz give me example thanks

Here you use an inlinelayout(false,fill) where horizontal=false and align=fill. Then your fields are displayed verticaly.

To have text label and textfield on the same line you need to add them to an other component :

<screen title="helloworld">

<container style="layout:inlinelayout(false,fill);align:fill-center">

<container style="layout:borderlayout">

<text style="layout-data:bld(west)">Người dùng</text>

<textfield id="txtUser" constraints="text" style="border:1;border-color:black"></textfield>

</container>

<container style="layout:borderlayout">

<text style="layout-data:bld(west)">Mật khẩu</text>

<textfield id="txtPass" constraints="password" style="border:1;border-color:black"></textfield>

</container>

<button>Login</button>

</container>

</screen>

 

You need to notice that first container align need to be set to fill-center else your textfield will be sized to 0 because they don't have any contents. And button layout-data is unused ther because it isn't placed in a staticlayouted widget.

Here I use two container with borderLayout, but if you want to align textfileds, you need to use tableLayout :

<screen title="helloworld">

<container style="layout:tablelayout;align:fill-center">

<text>Người dùng</text>

<textfield id="txtUser" constraints="text" style="min-size:60 0;border:1;border-color:black" />

<break />

<text>Mật khẩu</text>

<textfield id="txtPass" constraints="password" style="min-size:60 0;border:1;border-color:black" />

<break />

<button style="span:2 1">Login</button>

</container>

</screen>

Notice here the use of min-size to have a consistance size to the textfields.