@tagustin
Hi Teresa. Hope you are doing well also!
So, you're actually doing more than you need to in your gallery controls. When you use a Flexible Height gallery, it will adjust its size based on what is visible and what is not. You don't need to mess with the height property or be so specific on the placement of the controls in it.
A couple of things to consider:
1) For your Icon. Make it one icon. Hiding controls and overlaying with another that is visible is generally not a good practice.
So, for the View/Hide Icon, make it just one Icon and set the Icon property to:
If(varAccordion = ThisItem.ID, Icon.Hide, Icon.View)
2) Reference what you already have! Do your visible formula once and then reference the control that contains that formula.
So, for your lblActionItemOnDetails Visible property, set it to:
varAccordion = ThisItem.ID || yourExpandAllToggle.Value
Then all the other controls in your gallery can reference the lblActionItemOnDetails Visible property.
i.e. lblHelpfullInfoOn Visible property: lblActionItemOnDetails.Visible
3) On your toggle, you can get rid of all the OnCheck and UnCheck stuff...you don't need to be so programmatic. Your new Visible property formulas above will now address the toggle - that is all you need.
That is it! Set your gallery controls as needed (you don't need to be specific with adding heights and Y values - just place as needed)
Do not put a formula in the TemplateHeight property. Just set the template height in the designer (size as needed) and leave it.
When controls are visible in the gallery, the gallery will resize. When not, it will shrink.
I hope this is helpful for you.