We want to implement a program with a title bar and a status bar, and to support stretching, which includes minimizing, maximizing, as shown below:
Xml:
<?XML version= "1.0" encoding= "Utf-8" standalone= "yes"?><Windowsize= "695,542"> <Verticallayoutwidth= "657"Height= "517"Bkcolor= "#FFA0A0A4"> <Horizontallayoutname= "title"Height= "+"Bkcolor= "#FF63A6F1"> <Buttontext= "X"bordersize= "1"float= "true"POS= "608,0,0,0"width= "$"Height= "+"Bkcolor= "#FF008067"Bkcolor2= "#0000C020"bordercolor= "#00FFFF00"TextColor= "#FF000000"Disabledtextcolor= "#FFA7A6AA"Align= "Center" /> </Horizontallayout> <Horizontallayoutname= "Mid"Bkcolor= "#FFBABABA" /> <Horizontallayout name= "status" height = "+"Bkcolor= "#FF808080" /> </Verticallayout></Window>
In Duidesigner, drag the window border to see the effect, and the position of the title bar and status bar is unchanged, which changes with the size of the window.
Look at the attribute, found that the status and title have property height, and the middle, what properties are not. The window settings are as follows:
Title
Mid
As you can tell, POS can set a stretch operation with a float property of false , so not just layout can be stretched freely with the window (which is exactly what it should be), and normal controls can, as long as float is false.
float means float, and when it is true, it floats above the window, and the position will never change (relative to the layout that owns it).
When it is false, it floats, stops on the water, and flows with it, so it can be changed by running Water (LAYOUT).
Note that only right and bottom are valid. If it is not 0, then it is the height, i.e. it does not change size with the parent layout (the position cannot be changed). To 0 is to change the size with the parent layout.
In the above example, the Close button does not change position with the window because we see that its float is true. What if we want it to stop at the far right forever?
Look at the following XML:
<?XML version= "1.0" encoding= "Utf-8" standalone= "yes"?><Windowsize= "695,542"> <Verticallayoutwidth= "657"Height= "517"Bkcolor= "#FFA0A0A4"> <Horizontallayoutname= "title"Height= "+"Bkcolor= "#FF63A6F1"> <control/> <Buttontext= "X"bordersize= "1"maxwidth= "POS= "608,0,0,0"width= "$"Height= "+"Bkcolor= "#FF008067"Bkcolor2= "#0000C020"bordercolor= "#00FFFF00"TextColor= "#FF000000"Disabledtextcolor= "#FFA7A6AA"Align= "Center" /> </Horizontallayout> <Horizontallayoutname= "Mid"Bkcolor= "#FFBABABA" /> <Horizontallayoutname= "status"Height= "+"Bkcolor= "#FF808080" /> </Verticallayout></Window>
We added a float Control and set the Close button's maxwidth to 60 while the float was set to False (the Float property defaults to false).
This setting means that the Close button has a maximum width of 60, so it cannot be pulled wider.
On its left there is a float, which can be arbitrarily stretched. So when the window is stretched, the Close button is 60, and the control on the left is stretched to the window width.
If the rightmost button is maximized and minimized, the principle of implementation is the same. Of course, you can add a layout to the right, with the minimize, Maximize, and Close buttons on the layout, which makes the hierarchy more powerful and easier to manage and modify.
Duilib Tutorial-Automatic Layout 1