In the TemplateSize property of the gallery, use:

If(Self.AllItemsCount > 0,Self.Height / Self.AllItemsCount)
Then for each individual item in your gallery, change their size relative to the TemplateSize property. For example, if you have a label, you can set its height property as:
Min(40,Parent.TemplateHeight)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If this post or my previous reply was useful in other ways, please consider giving it Thumbs Up.