cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Using Parent.Size for responsive font size within gallery

Hello,


I am successfully using Parent.Size on several objects to change the font size depending on the screen size, as shown here: 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-responsive-layout

Parent.Width *  
    Switch(Parent.Size,  
        ScreenSize.Small, 0.5,  
        ScreenSize.Medium, 0.3,  
        0.25)

 I am now trying to achieve the same thing within a gallery, when the screen size is set to ScreenSize.ExtraLarge update the font size to something a bit bigger.

The problem I run into is now I am in a gallery Parent is something else so Parent.Size no longer works. I've looked under App. and Screen. for something similar but can't find what I want.

 

How can I get around this?

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@npotter 

You can get to that with App.ActiveScreen.Size

App.ActiveScreen.Width *  
    Switch(App.ActiveScreen.Size,  
        ScreenSize.Small, 0.5,  
        ScreenSize.Medium, 0.3,  
        0.25)

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

7 REPLIES 7
Super User III
Super User III

@npotter 

You can get to that with App.ActiveScreen.Size

App.ActiveScreen.Width *  
    Switch(App.ActiveScreen.Size,  
        ScreenSize.Small, 0.5,  
        ScreenSize.Medium, 0.3,  
        0.25)

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

 Thanks for the quick reply.

 

I've tried App.ActiveScreen.Size in a label so can confirm it works and updates at the same time as Parent.Size however the font sizes in my gallery don't seem to be changing while using it.

 

I'm using a slightly different formula to the example however this is working outside the gallery. Maybe it is to do with the gallery?

Switch(
    App.ActiveScreen.Size,
    ScreenSize.ExtraLarge,
    14,
    11)

 

@npotter 

It shouldn't be an issue.  That value would be the same in or out of a Gallery.

If you want to confirm this, put a label in your Gallery and set its text to App.ActiveScreen.Size and see if it responds as you expect.

If so, then I would review your font size formulas again and I would assume you also would be resizing the entire Gallery based on the screen size?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

I have tried putting a label in my gallery and set it's text to App.ActiveScreen.Size and the label doesn't update when I resize the screen. (A label outside the gallery is updating as expected).

 

Any other ideas? 🤔

 

Yeah, the whole gallery is set to resize based on the screen size. This bit responds as expected.

@npotter 

Hmmm, I would not have expected that!  

Well, in that case - use the label!

If the label outside of the Gallery responds properly, then just reference that.

ex.  lblSize text property : App.ActiveScreen.Size

in the Gallery - Value(lblSize.Text)

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

I think the issue is actually with App.ActiveScreen.Size.

 

When I tested it in a label outside of the gallery it was actually part of a bigger label I was using:

"Height: " & App.Height & " Width: " & App.Width & " ParentSize: " & Parent.Size  & " ActiveScreenSize: " & App.ActiveScreen.Size

I think having other properties updating allowed App.ActiveScreen.Size to update.


I just tried to create a label for App.ActiveScreen.Size on it's own (Outside of the gallery) to try your suggestion and it didn't update when I resized the screen. (which would be why it didn't work in the gallery!)

 

If instead I create a label outside the gallery with Parent.Size I can reference this within the gallery just fine and it updates OK.

 

Not sure if that was by design or a bug somewhere!

 

Thanks for all your help!

@npotter 

Yep, that was where I was going next...just use Parent.Size in the outer label.  

Glad you got to it.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (9,220)