Skip to content

Commit

Permalink
Fix linear layout size calculation to properly account for item margi…
Browse files Browse the repository at this point in the history
…ns (#1469)

* Better margin handling in WeightlessLinearLayout

* Add margin debugging layouts
  • Loading branch information
jyaganeh authored Jun 28, 2024
1 parent de401a4 commit 7575833
Show file tree
Hide file tree
Showing 3 changed files with 414 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
---
version: 1
presentation:
dismiss_on_touch_outside: true
type: modal
default_placement:
size:
width: 95%
height: 30%
shade_color:
default:
hex: '#000000'
alpha: 0.7
view:
type: container
background_color:
default:
hex: "#ffffff"
alpha: 1
border:
stroke_color:
default:
hex: "#000000"
alpha: 1
stroke_width: 3
items:
# TOP-LEVEL LINEAR LAYOUT
- position:
horizontal: center
vertical: center
size:
height: 100%
width: 100%
view:
type: linear_layout
direction: vertical
background_color:
default:
hex: "#ffffff"
alpha: 0.35
items:
- size:
width: 100%
height: 50%
view:
type: linear_layout
direction: horizontal
items:
- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 0
end: 0
view:
type: label
text: 100%
background_color:
default:
hex: "#FF0000"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 0
end: 0
view:
type: label
text: 100%
background_color:
default:
hex: "#00FF00"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 0
end: 0
view:
type: label
text: 100%
background_color:
default:
hex: "#0000FF"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12
- size:
width: 100%
height: 50%
view:
type: linear_layout
direction: horizontal
items:
- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 16
end: 16
view:
type: label
text: 100%
background_color:
default:
hex: "#FF0000"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 16
end: 16
view:
type: label
text: 100%
background_color:
default:
hex: "#00FF00"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 16
end: 16
view:
type: label
text: 100%
background_color:
default:
hex: "#0000FF"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
---
version: 1
presentation:
dismiss_on_touch_outside: true
type: modal
default_placement:
size:
width: 95%
height: 30%
shade_color:
default:
hex: '#000000'
alpha: 0.7
view:
type: container
background_color:
default:
hex: "#ffffff"
alpha: 1
border:
stroke_color:
default:
hex: "#000000"
alpha: 1
stroke_width: 3
items:
# TOP-LEVEL LINEAR LAYOUT
- position:
horizontal: center
vertical: center
size:
height: 100%
width: 100%
view:
type: linear_layout
direction: horizontal
background_color:
default:
hex: "#ffffff"
alpha: 0.35
items:
- size:
width: 50%
height: 100%
view:
type: linear_layout
direction: vertical
items:
- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 0
end: 0
view:
type: label
text: 100%
background_color:
default:
hex: "#FF0000"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 0
end: 0
view:
type: label
text: 100%
background_color:
default:
hex: "#00FF00"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
start: 0
end: 0
view:
type: label
text: 100%
background_color:
default:
hex: "#0000FF"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12
- size:
width: 50%
height: 100%
view:
type: linear_layout
direction: vertical
items:
- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
top: 16
bottom: 16
view:
type: label
text: 100%
background_color:
default:
hex: "#FF0000"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
top: 16
bottom: 16
view:
type: label
text: 100%
background_color:
default:
hex: "#00FF00"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12

- position:
horizontal: center
vertical: center
size:
width: 100%
height: 100%
margin:
top: 16
bottom: 16
view:
type: label
text: 100%
background_color:
default:
hex: "#0000FF"
alpha: 0.35
text_appearance:
color:
default:
hex: "#000000"
alpha: 1
alignment: center
font_size: 12
Loading

0 comments on commit 7575833

Please sign in to comment.