Controls spacing

The last row may contain spacers, but these also need the correct
margins so all controls retain the same dimensions.

Fixes: 190089614
Test: manual (controls main activity + add/edit controls)
Change-Id: Ie19b98405213bc0f9ef53a11f44cb8013139e562
This commit is contained in:
Matt Pietal
2021-06-09 08:46:37 -04:00
parent 97be319829
commit b8daba75e7

View File

@@ -422,8 +422,12 @@ class ControlsUiControllerImpl @Inject constructor (
// add spacers if necessary to keep control size consistent
val mod = selectedStructure.controls.size % maxColumns
var spacersToAdd = if (mod == 0) 0 else maxColumns - mod
val margin = context.resources.getDimensionPixelSize(R.dimen.control_spacing)
while (spacersToAdd > 0) {
lastRow.addView(Space(context), LinearLayout.LayoutParams(0, 0, 1f))
val lp = LinearLayout.LayoutParams(0, 0, 1f).apply {
setMarginStart(margin)
}
lastRow.addView(Space(context), lp)
spacersToAdd--
}
}