How many characters in ListView line?

jpvniekerk

Active Member
Licensed User
Longtime User
I have a listview showing info from a database table. I make up the line with four different fields. Due to the length of the fields I truncate them to show limited string lengths of each field.
When I look at it on a small phone it looks good, but on a larger device (tablet) I can show more information.

I am trying to figure out how to determine programmatically how many characters can fit in a line, depending on the device.

The main settings for the listview line is
B4X:
ListView1.TwoLinesLayout.SecondLabel.Height = 13dip
ListView1.TwoLinesLayout.SecondLabel.Typeface = Typeface.MONOSPACE
ListView1.TwoLinesLayout.SecondLabel.TextSize = 10

I've determined (manually) the following:
Tablet (800 Pixels) can fit 87 characters
Note II (720 Pixels) can fit 59 characters
Phone (320 Pixels) can fit 52 characters

It is clearly not a direct relationship between pixels and number of characters (due to different scaling?)

I will appreciate it if someone can help me with a way to calculate the number of characters I can fit in a line in my program, to optimize the screen usage for each device.
 
Last edited:
Top