Android Question Font size for different devices

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello, with the designer I use the percentages of x and y to size panels, labels so that all the views are well proportioned according to the sizes of the screens (smartphones, tablets) where the application will be installed. However, how to adjust the size of fonts that are too small on tablets or too big on smartphones. Thank you for your help
 

Attachments

  • Jh_Phone.jpg
    Jh_Phone.jpg
    43.4 KB · Views: 284
  • Jh_Tab.jpg
    Jh_Tab.jpg
    47.7 KB · Views: 296

Erel

B4X founder
Staff member
Licensed User
Longtime User
with the designer I use the percentages of x and y to size panels, labels so that all the views are well proportioned according to the sizes of the screens
Usually a mistake. Use anchors instead. A tablet layout shouldn't look like an oversized phone layout.

AutoScaleAll can help a bit with the text size, if you are using a single phone sized variant. It will increase the text size.
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
OK with Designer and AutoscrollAll, but if I add views using code because for example I have to add views in a scroll like this:
P.AddView(L1,11%x ,1%y,70%x,P.Height/4.2)
Font size does not follow, what is the trick?
 
Upvote 0

roumei

Active Member
Licensed User
One option is to add some out-of-bound labels to your layout with the desired fonts and fontsizes. Create some global variables and use them for the programmatically created views.
Labels.jpg

B4X:
' Process_Globals
Private Settings_BigFont As Typeface
Private Settings_SmallFont As Typeface

' after LoadLayout in Activity_Create or B4XPage_Created
Settings_SmallFont = lblTextFont.Typeface
Settings_BigFont = lblTextBigFont.Typeface
 
Upvote 0
Top