Android Question Font size

Pete_S

Member
Licensed User
I have a simple multiple choice app for learning Chinese or Thai language. It loads words and definitions from an Excel file. Some definitions are long in length, some are short in length.

Is there a clever way to set the font width based on the width of the device?
 

Attachments

Pete_S

Member
Licensed User
Right now (if you look at the screenshots from my first post) I use 1 Label and 4 Buttons. Are you saying to add/embed these Views INSIDE a xCustomListView? How will it prevent the text cutoffs that I'm currently experiencing? Or do you suggesting I REPLACE these Views with a xCustomListView?

I will try to do it.

Is xCustomListView.zip and CustomListView.bas from https://www.b4x.com/android/forum/t...listview-cross-platform-customlistview.84501/ the best examples for me to look at?
 

DonManfred

Expert
Licensed User

Pete_S

Member
Licensed User

Attachments

klaus

Expert
Licensed User
Attached you find a modified version with an improved version of the first link.
The problem with Buttons is that they have a padding, which means that the text area is smaller than the view dimensions.
The StringUtils.MeasureMultilineTextHeight method doesn't take into account the padding.
 

Attachments

Pete_S

Member
Licensed User
Thanks Klaus
Most of the text I use adjusts correctly thanks to your code but there are some exceptions. To see some of these exceptions look at the attached screenshot. As you can see the Label1 and Button2 lines are problematic.

B4X:
SetTextSize(Label1, "星期 (xing1 qi1)")
SetTextSize(Button1, txt)
SetTextSize(Button2, "vegetables; greens; (non-staple) food")
SetTextSize(Button3, "小 (xiao3)")
SetTextSize(Button4, "hi")
 

Attachments

klaus

Expert
Licensed User
Set the limit to
Private limit = 0.001 As Float
instaed of
Private limit = 0.5 As Float
It seems that the text is at the limit betwwen one line and two lines:
On my device:
TextSize = 19.166 one line
TextSize = 19.167 two lines
 
Top