Pete_S Member Licensed User Feb 5, 2019 #1 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 font bad 2.PNG 409.5 KB · Views: 469 font bad.png 368.7 KB · Views: 518
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?
Erel B4X founder Staff member Licensed User Longtime User Feb 5, 2019 #2 Use xCustomListView and add the items with clv.AddTextItem. Upvote 0
Pete_S Member Licensed User Feb 10, 2019 #3 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? Upvote 0
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?
Pete_S Member Licensed User Feb 10, 2019 #5 Which question are you saying "yes" to? I asked 3 questions. Upvote 0
DonManfred Expert Licensed User Longtime User Feb 10, 2019 #6 Pete_S said: Are you saying to add/embed these Views INSIDE a xCustomListView? Click to expand... yes. Use clv.AddTextItem. Pete_S said: How will it prevent the text cutoffs that I'm currently experiencing? Click to expand... Check the code inside the class module from the sub AddTextItem. It calculates the heigth needed. Pete_S said: Which question are you saying "yes" to? Click to expand... The third one. Upvote 0
Pete_S said: Are you saying to add/embed these Views INSIDE a xCustomListView? Click to expand... yes. Use clv.AddTextItem. Pete_S said: How will it prevent the text cutoffs that I'm currently experiencing? Click to expand... Check the code inside the class module from the sub AddTextItem. It calculates the heigth needed. Pete_S said: Which question are you saying "yes" to? Click to expand... The third one.
Pete_S Member Licensed User Feb 11, 2019 #7 I am still trying to solve this "automatically adjust font size by size or length of text" issue for labels and buttons. I have created a small demo to show the problem. As you can see in my attachment, I tried applying 2 different solutions: https://www.b4x.com/android/forum/threads/label-utils.39338/#content https://www.b4x.com/android/forum/threads/automatically-set-the-text-size.93288/#content Attachments LabelAndButtonTextFitting.zip LabelAndButtonTextFitting.zip 150.9 KB · Views: 312 Upvote 0
I am still trying to solve this "automatically adjust font size by size or length of text" issue for labels and buttons. I have created a small demo to show the problem. As you can see in my attachment, I tried applying 2 different solutions: https://www.b4x.com/android/forum/threads/label-utils.39338/#content https://www.b4x.com/android/forum/threads/automatically-set-the-text-size.93288/#content
Erel B4X founder Staff member Licensed User Longtime User Feb 11, 2019 #8 Why aren't you using xCustomListView? Upvote 0
klaus Expert Licensed User Longtime User Feb 11, 2019 #9 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 LabelAndButtonTextFitting1.zip LabelAndButtonTextFitting1.zip 7.9 KB · Views: 282 Upvote 0
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.
Pete_S Member Licensed User Feb 11, 2019 #10 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. Code: Copy SetTextSize(Label1, "星期 (xing1 qi1)") SetTextSize(Button1, txt) SetTextSize(Button2, "vegetables; greens; (non-staple) food") SetTextSize(Button3, "小 (xiao3)") SetTextSize(Button4, "hi") Attachments ss.jpg 42.3 KB · Views: 417 Upvote 0
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. Code: Copy SetTextSize(Label1, "星期 (xing1 qi1)") SetTextSize(Button1, txt) SetTextSize(Button2, "vegetables; greens; (non-staple) food") SetTextSize(Button3, "小 (xiao3)") SetTextSize(Button4, "hi")
klaus Expert Licensed User Longtime User Feb 11, 2019 #11 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 Upvote 0
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
klaus Expert Licensed User Longtime User Feb 12, 2019 #12 Another suggestion, more efficient. Set the limit to Private limit = 0.2 As Float And replace: lbl.TextSize = lblDummy.TextSize by lbl.TextSize = lblDummy.TextSize - 0.2 Upvote 0
Another suggestion, more efficient. Set the limit to Private limit = 0.2 As Float And replace: lbl.TextSize = lblDummy.TextSize by lbl.TextSize = lblDummy.TextSize - 0.2