Problem with Font-scaling using %X%Y from code

moster67

Expert
Licensed User
Longtime User
I got a problem with Font-scaling using view-locations in terms of %X and %Y. I am using the method posted by dlfallen in his post posted here:

http://www.b4x.com/forum/52178-post1.html

My normal emulator-app is using 320-480 scale=1 (160dpi). I am trying to add visual support for Tablets in an easy way and the method shown by dlfallen in above post works very well as to the positioning of the views themselves but unfortunately the fonts will not scale correctly in the Samsung tablet-emulator (using 1280-800 scale=1 (160dpi).

In my code I set the layout as follows:

B4X:
txtBoxIP.SetLayout(29.375%X,10%Y,70%X,8.54166666666667%Y) 
'94-48-224-41

I attach 2 images where you can see that the fonts are not being resized on the tablet (or they remain very small on the tablet).

I was under the impression that fonts would also be scaled automatically or am I wrong? Should I be using dip instead of %X and %Y? In this regard, what is the difference in using dip and %X and %Y (if any)?

Many thanks in advance for your help.
 

Attachments

  • 320_480.jpg
    320_480.jpg
    13.8 KB · Views: 242
  • 1280_800_tablet.jpg
    1280_800_tablet.jpg
    13.5 KB · Views: 237
Last edited:

moster67

Expert
Licensed User
Longtime User
What do you mean with a scaled down emulator? Do you mean the last step when launching the emulator i.e. Launch Options and the possibility to scale display to real size? If yes, what parameters should I use?


Are you sure that the fonts are really too small? It seems from the screenshot that you are working with a scaled down emulator.

Font size is measured in physical units. This means that there is no need to scale the font size
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
OK, I was not aware of the REAL Samsung-emulator. I installed it and now fonts and views are showing up correctly.

In any case, the so called "tablet"-screenshot in my first post, was created by targeting 3.1 and using density = 160 dpi and resolution=WXGA as suggested by default in the set-up of the emulators. With this scenario, I still get very small fonts. Perhaps, all honeycomb-devices have higher density-values such as 240 dpi or more. If yes, then the layout should be OK, I guess.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
In related news.......

I've gotten to the point where I am creating several different layout variants for each layout in my app. I've noticed too that everything is smaller on the larger (tablet) AVDs. I know part of this is because I am also shrinking the AVD a bit to fit on my monitor, but to me it looks like the text, buttons and input boxes are going to be tiny.

I've read here that 'Android automatically adjusts the font size', but I assume that is only true when it is scaling a layout? I am guessing that in a case where you have several different layout variants (i.e. for a small phone and a large tablet), it will use whatever size is configured in the label's properties for that particular variant?

Getting to my question: If I increase the size of a text input box and its font size in a 'tablet' variant, will the font size also change in the other layout variants? I know the size of the view shouldn't, but I am not sure about the font size.

These layout variants are kicking my ass. For Windows, I made one interface. For Android, as much as I am happy with my interface, doing it 4 or 5 times and moving things around is wearing on me. :)
 
Last edited:
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
As I wrote above, font size is measured in physical units, not pixels. The same font size should look the same on all devices.

All layout variants share the same font size.

Sorry about that... I was in a bit of a rush to post my question before I had some errands to run but I just re-read it so I think I understand. I think part of my problem is that I don't have a physical device to look at this on, so looking at scaled down AVDs is skewing my perspective on this stuff.

One thing I am uncertain of is that I don't know what tablet users expect. Does a tiny panel with a text input and a couple buttons centered in the screen (relative to the overall screen size) look odd on a tablet? Or does it look perfectly normal considering it is essentially the same size physically as it would be on a phone? I see how small it looks and I feel like I need to enlarge it all for fear that people would complain about the tiny views straining their eyes. :SHOCKED:
 
Upvote 0
Top