Android Question Font size

fishwolf

Well-Known Member
Licensed User
Longtime User
is it possible set font size in app indipendent from size system?

i would have the same font size in app if i have system size big or small

Thanks
 

asales

Expert
Licensed User
Longtime User
Check this:
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
thanks, work fine

but for b4xtable cell?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
but for b4xtable cell?
I hope I am understanding the question. If not, clarify what you see and what you want to see with code and screenshot
B4X:
Dim xfont As B4XFont=xui.CreateFont(Typeface.DEFAULT, 18/access.GetUserFontScale)  'reset font to default after user changed accessinility
B4XTable1.LabelsFont = xfont
'the 2 lines must be set before defining table columns
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
work fine for row, but the header, page and search not changed

i'm tring to use without effect
B4X:
B4XTable1.HeaderFont = xcode
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
work fine for row, but the header, page and search not changed
For the header labels use this:
B4X:
Dim xfontH As B4XFont=xui.CreateFont(Typeface.DEFAULT_BOLD, 18/access.GetUserFontScale)  'reset font to default after user changed accessinility
B4XTable1.HeaderFont = xfontH
For the search field use this code. For this, you need to put is after the columns were defined not before.:
B4X:
B4XTable1.SearchField.TextField.Font = xui.CreateFont(Typeface.DEFAULT, 16/access.GetUserFontScale)
Please be more clear and give more details and code to help us help you, if you need additional help
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
i have noticed that the font of AcToolbarLight is reduced each times that i go to into activity.

exist a method for recovery original font size?
 
Last edited:
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
header doesn't work. And search font?

 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
header doesn't work. And search font?
They need to be placed in the correct place in the code. I tested them on my B4XTble and they work. The header code has to be before you assign the B4XTable columns, for the search it is after. If you want to attach a project, provided no sensitive data. some of the members including myself will take a look, or you can show with code where you placed these lines in the code.
Without Resetting AccessibilyFont:
B4XTable1.HeaderFont = xui.CreateDefaultBoldFont(24) 'header

With Resetting AccessibilyFont:
Dim xfontH As B4XFont=xui.CreateFont(Typeface.DEFAULT_BOLD, 24/access.GetUserFontScale) 'reset font to default after user changed accessinility
B4XTable1.HeaderFont = xfontH

 

Attachments

  • 1635955248161.png
    23.7 KB · Views: 163
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User

sorry for the delay, User data are fake

now header font is correct,
but i have a error when set the search font

B4X:
java.lang.RuntimeException: Class instance was not initialized (b4xfloattextfield)

B4X:
Sub Globals
Private B4XTable1 As B4XTable
Private StateColumn As B4XTableColumn
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim access As Accessibility
Dim xui As XUI
   
    Activity.LoadLayout("main")
  
    B4XTable1.Clear

    ' i have tied also here B4XTable1.SearchField.TextField.Font = xui.CreateFont(Typeface.DEFAULT, 6/access.GetUserFontScale)
    B4XTable1.HeaderFont = xui.CreateFont(Typeface.DEFAULT_BOLD, 14/access.GetUserFontScale)

   
    B4XTable1.MaximumRowsPerPage = 15
   
    StateColumn = B4XTable1.AddColumn("Human", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
   
    StateColumn = B4XTable1.AddColumn("Dog", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
    StateColumn = B4XTable1.AddColumn("D1", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
    StateColumn = B4XTable1.AddColumn("D2", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
    StateColumn = B4XTable1.AddColumn("D3", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
   
     ' i have tied also here B4XTable1.SearchField.TextField.Font = xui.CreateFont(Typeface.DEFAULT, 6/access.GetUserFontScale)

    B4XTable1.NumberOfFrozenColumns = 2
   
    Dim data As List
    data.Initialize
    For i = 1 To 15

        data.Add(Array("Mario Rossi", "Pluto", "5,5", "3", "2"))
       
    Next

    B4XTable1.SetData(data)
   
    B4XTable1.LabelsFont = xui.CreateFont(Typeface.DEFAULT, 14/access.GetUserFontScale)
   
    B4XTable1.SearchField.TextField.Font = xui.CreateFont(Typeface.DEFAULT, 6/access.GetUserFontScale)
   
    'B4XTable1.Refresh
   
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
but i have a error when set the search font
Here is the complete corrected project. Tested and works after a slight tuning. You needed to check the B4X Views library in the IDE library pane. It was not checked. Also, you needed to add a Sleep(0) immediately after you load you main layout to allow an internal B4XTable layout to be loaded.
B4X:
Sub Globals
    Private B4XTable1 As B4XTable
    Private StateColumn As B4XTableColumn
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim access As Accessibility
    Dim xui As XUI
   
    Activity.LoadLayout("main")  'You also need to check the B4X Views library
    
      Sleep(0)  'Needed because of an internal layout has to be allowed to load first. Line Added by Mahares
  
    B4XTable1.Clear

    B4XTable1.HeaderFont = xui.CreateFont(Typeface.DEFAULT_BOLD, 14/access.GetUserFontScale)
    B4XTable1.LabelsFont = xui.CreateFont(Typeface.DEFAULT, 14/access.GetUserFontScale)

    B4XTable1.MaximumRowsPerPage = 15
   
    StateColumn = B4XTable1.AddColumn("Human", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
   
    StateColumn = B4XTable1.AddColumn("Dog", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
    StateColumn = B4XTable1.AddColumn("D1", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
    StateColumn = B4XTable1.AddColumn("D2", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
    StateColumn = B4XTable1.AddColumn("D3", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 30%x
    
    B4XTable1.SearchField.TextField.Font = xui.CreateFont(Typeface.DEFAULT, 6/access.GetUserFontScale)
    B4XTable1.NumberOfFrozenColumns = 2
   
    Dim data As List
    data.Initialize
    For i = 1 To 15
        data.Add(Array("Mario Rossi", "Pluto", "5,5", "3", "2"))    
    Next
    B4XTable1.SetData(data)
End Sub
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Continue to doesn't work fine

i'm usin b4a 11.00 with all last verson of libraries
 

Attachments

  • TableWithBigFont.zip
    9.6 KB · Views: 187
  • TableWithBigFont.jpg
    172.1 KB · Views: 155
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Continue to doesn't work fine
There are several views in the header panel besides the search box text field. You have to go through all of them. As an example:
B4X:
B4XTable1.lblNumber.Font = xui.CreateFont(Typeface.DEFAULT, 14/access.GetUserFontScale)  'this is for the number showing as the page you are looking at
There are other views like: : B4XTable1.SearchField.lblV, B4XTable1.SearchField.lblClear, and others like the arrows, etc. which I did not look at. At this stage, you can follow up and perhaps, someone can take a look at your project accessibility further.It may not hurt to add this at the end: B4XTable1.SearchField.Update
Here are all the views hierarchy in the hidden B4XTable layout
I added this a few minutes later as an example for the labels inside a panel (PnlPages) that is inside pnlHeader. You can try it. It reduces the size::
B4X:
For Each v As B4XView In B4XTable1.pnlHeader.GetView(2).GetAllViewsRecursive
        If v Is Label Then
            Dim x As Label=v
            x.TextSize=24/access.GetUserFontScale
'            x.TextSize=24
        End If       
    Next


B4X:
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Maybe something like this will work better for you as far as the header panel views: See comparison with accessibility in effect and not in effect screenshots I tried them with a textsize=20. You can try different sizes.. You can see the difference.
B4X:
For Each v As B4XView In B4XTable1.pnlHeader.GetAllViewsRecursive
        If v.Tag Is B4XFloatTextField Then
            Dim y As B4XFloatTextField =v.tag
            
            y.HintFont= xui.CreateFont(Typeface.DEFAULT,20/access.GetUserFontScale)
'            y.HintFont= xui.CreateFont(Typeface.DEFAULT,20)
            
            y.LargeLabelTextSize=20/access.GetUserFontScale
'            y.LargeLabelTextSize=20
            y.Update
        else if v Is Label Then
            Dim x As B4XView=v
            
            x.TextSize=20/access.GetUserFontScale
'            x.TextSize=20
            
            x.TextColor=xui.Color_Blue
        else if v Is Panel Then
            Dim z As B4XView =v
            z.Color =xui.Color_Cyan
        End If
    Next



B4X:
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User

Dosen't work fine for all elements of interface, when write filter search, it's very, very little.

Is it possible disable system size from my app?

or get the system size different from standard and write a warning message?

is it impossible manage in this mode
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…