Responsive Screen Sizing

So basically in your code above, the fontSizeAspect is the screen size of your phone?? And if the fontSizeAspect is the screen size of your phone, you would multiply that by screen width divided by 411? Or is 411 the screen size of your device?

If the screenwidth of my phone is 411 and the screenwidth of someone else is also 411 then the fontsize will be exactly what i showed because it will be 24 * 411/411 which is a ratio of 1 so 24.

Say the screensize of the other is 500 then the app will show 24 * 500/411 is fontsize of 29.

3 Likes

So basically in your second example, the font size would be responsive and adjust to a bigger screen size correct?

Yes that is correct. Because the other has a bigger screen it will be able to show a bigger letter. If the other has a smaller screen then the font will be smaller.

2 Likes

Great idea thanks for the help!

1 Like

Not my original idea but i use it a lot in my apps.

1 Like

Majority of the phones are 360dp however, there are phones with odd sizes, such as width size 540dp, 480dp, 384dp

Edit, Damn forgot Peter’s phone size 411dp

7 Likes

@Peter do you think http://screensiz.es/ would be of any use to figure out their 411?

It is density that determines that, Peter has either 2.6 or 3.5
bild

4 Likes

They didn’t add the Pixel 3/XL or Pixel 4/XL and it’s their own phone :expressionless:

1 Like

How to automatically adjust the dpi of an image?

Hi Peter, I am struggling here to ajust font size accordig to the size of screen. My problem is a little different because I need the text to have 90% the width of the screen. But your procedures gave me some ideas that I will work on as soon as possible.

That said, let me ask you one thing: If the result of fontresponsive procedure is not a natural number, what happens? I mean, the font size can be a not integer number, as 24.568? Or would it cause some bug?
I know it is a very silly question, feel free not to answer, but my phone is not working and due to this f****ing pandemia I can’t fix it, so I have to work without live testing or compiling the apk.
If the android system can’t work on not integers numbers for font size I will try to create a procedure that convert the number generated into the closest integer number.

I use this procedure in all my apps. There is no problem with the decimals

1 Like

It’s no different to setting vertical arrangement height to a percentage of screen height. If the screen height is 2160 pixels and you set the height to 12% it comes to 259.2 pixels which is obviously nonsense. I think Android OS will take care of it and round it.

1 Like

Font size has nothing to do with screen sizes.
Font size depends on the phone pixel density which varies from phone to phone.:point_down:

I suggest you to follow this method :point_down:
Screenshot_2020_0504_060547
If you want to set same size for all labels then instead of so many blocks, you can use “any Label” component.

2 Likes

Thanks, my friend. I will work with these procedures for now whithou bigger worries.

I suggest you to follow this method :point_down:

Very interesting to know it. I didn’t understand very well but I will read more about it and test with different phones when I can. Thanks for the tip.

1 Like

Actually, the system is already taking care of that by default in responsive mode, so no need to do this.

As far I remember it was you who actually suggested this method

1 Like

Maybe to find out how big the font size will be however, as I can’t recall that can you post a link where I stated that.



1 Like