Android Question Label text with big size font not displayed on some devices


Licensed User
Longtime User
Hi guys,
I have this problem for which I cannot find solution. Android 5.1(480x854). I have label which covers whole screen. It displays single letter. Font size is selected by user - can be very big (to cover whole screen width). When going up with font size, from a particular size this label stops displaying some letters. It is just empty. I thought that this is normal label behaviour -> text (in my case only one letter) is too big, so dont display it. So I tried to detect the moment when letter is too big to be displayed:

Dim measuredWidth As Float
measuredWidth = cvsText.MeasureStringWidth(lbl_A.Text,lbl_A.Typeface, lbl_A.TextSize)

And also (with same results):

Dim measuredWidth As Float
measuredWidth = cvsText.MeasureStringWidth(lbl_A.Text.CharAt(0),lbl_A.Typeface, lbl_A.TextSize)

... and compare measuredWidth with lbl_A.Width. I realized that measuredWidth was smaller than width of label (I also made similar comparsions with heights) but label was empty. I also tried measurement according to this post:

[B4X] [XUI] Accurate Text Measurement and Drawing

Dim mainScrText As String
Dim measuredWidth As Int
Dim cvs1 As B4XCanvas
Dim r As B4XRect
Dim f As B4XFont     
f = xui.CreateFont(Functions.GetTypeface(userTypefaceSelected),userTxtSizeSelected)
lbl_A.Typeface = Functions.GetTypeface(userTypefaceSelected)
lbl_A.TextSize = userTxtSizeSelected
lbl_A.Text = mainScrText.CharAt(scrTextPointer)
r = cvs1.MeasureText(lbl_A.Text,f)
measuredWidth = r.Width


Sub GetTypeface(n As Int) As Typeface

This measurement method returned also smaller measuredWidth than width of label (even smaller then using previous method), yet the label was still empty.

I set all padding values to zero for label and also for 2 parent panels. Label is displayed correctly, I used label borders to check it, it was covering whole screen nicely.

I was planing to post more code for you to point out what I am doing wrong, but then I tested code on different device (Android 4.4.2, smaller screen, smaller resolution, same font settings) to observe the behaviour. But on this device, even if user select very big font size (much more bigger than lable (font size = 600) label displays it - cropped off course, but it was there.

Back at first device (Android 5.1): other confusing thing is that at particular font size only some leters are not showing and others with measuredWidth even few pixels larger are show correctly. It seems I am missing something... : (

Could you please explain this behaviour? Confusing situation for me, don`t know which question is more relevant:
Why letters that are larger are displayed correctly and smaller ones are not?
Was there any changes regarding labels rendering text between Android 4 and 5?
Is there any flag that can be used to detect that label is not rendering text correctly?
Is there any other object that is more suitable for such thing than Label?

Many thanks for your time.


Licensed User
Longtime User
Thanks for answer. So the standard behaviour of label with too big font to display is cropping the text?
Upvote 0