Hello, can `margin` be applied to a view itself in...
# doodle
a
Hello, can
margin
be applied to a view itself instead of on the
constraint
?
n
No. The design choice was to have parents completely own layout instead of children specifying how they’d like to positioned.
a
So what we are doing is summing up child views height and width to give the parent view a size. But margins on constraint are not calculated which I understand it's intended. But is there a way to get that margin without hacking stuffs??
n
You can modify the parent height as part of the constraints, just make it
writable
(0.9.0). You can do this directly or via a composite property like
bottom:
lastView.bottom eq parent.bottom.writable + margin
. This will work as long as the parent isn’t being forced to a smaller size by any outside layout etc., and the views are constrained so they don’t collapse is the parent has a smaller height.
a
It works. But there's a bug.
If you don't combine with
view.height.preserve
the UI will freeze, no component will be displayed
Copy code
constrain(view){
    <http://it.top|it.top> eq   10
    it.left eq  10
    //it.height.preserve
    it.bottom eq parent.bottom.writable
}
Code to test with. When you uncomment the
it.height.preserve
it works.
Nevermind false alarm