Auto height, Containers and flexible font sizes in Power Apps

It is important that each control on your screen fits and that nothing overlaps. Auto Height and Containers can help you be with flexible font sizes.

Flexible font sizes

Have you ever tried adjusting the default font size on your mobile or Windows device? Then when you try to use your app, text doesn’t fit in the areas that are supposed to fit in. Some apps become really unusable.

An app that should look like this.

app with clearly visible text
app with clearly visible text

Might actually look like this when you increase the font size.

App with font sizes adjusted
App with font sizes adjusted

We have to consider all sorts of different fonts that may be used. And of course different letters will use a different amount of space. Calculating the size of the box without knowing the content is very difficult. Or even impossible!

So how do we avoid this in Power Apps.

Auto Height in Power Apps

Within Power Apps, we can set the Auto Height property. I’m really not sure why this isn’t just always set by default. As you can see in the below example my text now fits within the boxes however the boxes don’t fit anymore. As we can see the label controls are moving on top of each other.

App with containers that have autoheight enabled.
App with containers that have autoheight enabled.

Now there are two approaches. The first approach is to calculate the X and Y positions so that every control appears next and underneath each other.

Adding Containers

Now the next step is Containers. As the font size is varied using my slider the containers are resizing as they need to.

Added containers to my app
Added containers to my app

But even when we use containers we will still find issues with text not fitting.

Text issues as we resize the text
Text issues as we resize the text

The trick here is to make sure that the Horizontal containers inside my top level vertical containers need to have flexible height switched off.

Switch flexible height off
Switch flexible height off

And in addition to the flexible height setting, the Height property also needs to be calculated finding the tallest element within the Container.

App with text fitting
App with text fitting

Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

One thought on “Auto height, Containers and flexible font sizes in Power Apps

  1. Very nice scalable !!
    My fear is that this will boost the quantity of components on a screen. And MS warns makers about possible performance issues on that part.
    Just something to keep in mind.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.