Display problems on high res devices

Status
Not open for further replies.

hackhack

Active Member
Licensed User
Longtime User
I asked about this elsewhere, but since erel didn't know the answer I'm opening this thread more as a research thread - perhaps someone has an idea.

Originally I asked about Sense 4 (the skin on HTC's new devices), but since resolutions keep going up perhaps this shows up on other devices as well (has anyone tried?)

In the HTC display setups there is a setting called "Font Size", it has 4 choices "Small","Medium","Large","Extra Large". Setting this will then rescale the sense interface and HTC apps - which is handy since resolutions keep going up.

However many, if not most, apps just ignore this setting (and since many don't allow the user to set font size I now need a magnifying glass)

But the B4A apps are also affected by this setting (unless I'm doing something very stupid, in which case please tell me gently :) )

So I tried a test, 4 labels on a panel, with this in Activity_Create

B4X:
   Activity.LoadLayout("default")
   Label1.TextSize=30
   Label2.TextSize=30
   Label3.TextSize=30
   Label4.TextSize=30

And this in Activity_Resume

B4X:
   Label1.Text=Label1.TextSize & "(" & Activity.Width & ")"
   Label1.Typeface=Typeface.DEFAULT

   Label2.Text=Label2.TextSize & "(" & Activity.Height & ")"
   Label2.Typeface=Typeface.SANS_SERIF

   Label3.Text=Label3.TextSize & "(" & Label3.Height & ")"
   Label3.Typeface=Typeface.SERIF

   Label4.Text=Label4.TextSize & "(" & Label3.Width & ")"
   Label4.Typeface=Typeface.MONOSPACE

Sense supports screen capture, so I took a screen cap at each of the 4 settings. This is the same apk just run 4 times.


If someone has suggestions I'm sure I'm not the only one who'd like to hear it :)
 

Attachments

  • 1.small.png
    1.small.png
    29.1 KB · Views: 329
  • 2.medium.png
    2.medium.png
    31.8 KB · Views: 317
  • 3. large.png
    3. large.png
    34.3 KB · Views: 298
  • 4. extra large.png
    4. extra large.png
    34 KB · Views: 286
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Edit: in reply to post #19

I'm not sure why do you say that it is related to the visual designer.
It affects all views.
Just to avoid confusion, by default the font scale is 1.0.

How do you want to handle this value? Dividing the current text size by the font scale value is definitely not a good solution.

Each view has some internal padding. So for most labels and buttons nothing needs to be done.

Note that you can see this effect in the visual designer as well if you change the font scale.

If you do want to handle it then you can use the Reflection solution.

I know that you enjoy these arguments. Do know that I'm not going to reply on this thread anymore due to your consistent negative attitude.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Just to complete this discussion, if you want to ignore the user setting you can use this code (I think that it should not be used in most cases):
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   
   
   If GetUserFontScale <> 1 Then
      ForceScale(Activity)
   End If
End Sub

Sub ForceScale(p As Panel)
   Dim s As Float
   s = GetUserFontScale
   For i = 0 To p.NumberOfViews - 1
      If p.GetView(i) Is Label Then 'handles all views with text
         Dim t As Label
         t = p.GetView(i)
         t.TextSize = t.TextSize / s
      Else If p.GetView(i) Is Panel Then
         ForceScale(p.GetView(i))
      End If
   Next
End Sub

Sub GetUserFontScale As Float
   Dim R As Reflector
   R.Target = R.GetContext
   R.Target = R.RunMethod("getResources")
   R.Target=R.RunMethod("getConfiguration")
   Return R.GetField("fontScale")
End Sub
 
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
The font scaling applies to EditTexts too, so they may need tested for...although I remember reading a couple threads lately on how they are related and there was an order to check them, etc...maybe just checking Label includes them. I'll have to find that thread again and write down the hierarchy.

I'd imagine this would apply to any view containing text and views like the listview containing labels too unless they already account for it, so there could be some additional code for this. I think a unit option may be easier in the end and less of a load during Create. I may go make a Wish list item for it in case this thread gets any more heated/deleted.
 
Upvote 0

hackhack

Active Member
Licensed User
Longtime User
I know that you enjoy these arguments. Do know that I'm not going to reply on this thread anymore due to your consistent negative attitude.

You know wrong. I hate this, it ruins my day, and sometimes longer. Im negative because i feel dismissed.
More ontopic when I get offline
 
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
The big thing, for me at least, and I'm sure him or any other forum owner is foul language and not respecting those giving help...especially demanding or expecting it right that second. I use this for work and issues cause delays for me too as well as the boss and his "meetings" taking time away from development, but I know how long things take and I wait just like everyone else. In my timezone Erel and other users seem to be on here 8am-2pm CST...if I write something at 5pmCST I'm not going to get back on at 5:30 and wonder where my answers are. This font issue while mostly on ICS can actually be on any device. And, it is Android doing it, not B4A. One of the reasons I more fully chose B4A was the developer. He replies very well to queries and things here.

Probably the worst experience I ever had was with developers of SmartFTP and of WYSIWYG Web Builder. They either denied bugs, tried to blame me or other users, had lame responses that being a developer I knew was false, or took things too personal. I dropped both of their products and forums which could have been very good products with someone else in charge. B4A has areas of improvement possible, and I'm sure I drive him nuts with requests coming from my background, but I respect his answers and he devotes a lot of his time here.
 
Upvote 0
Status
Not open for further replies.
Top