Addo Well-Known Member Licensed User Longtime User May 11, 2018 #1 i am trying to set a different font sized to a label i want to make this label height dynamically change based on its text length and size something like whats app expanding the label text based on the text length
i am trying to set a different font sized to a label i want to make this label height dynamically change based on its text length and size something like whats app expanding the label text based on the text length
LucaMs Expert Licensed User Longtime User May 11, 2018 #2 https://www.b4x.com/android/forum/threads/custom-view-autotextsizelabel.30642/#post177986 https://www.b4x.com/android/forum/threads/b4x-xui-accurate-text-measurement-and-drawing.92810/ Upvote 0
https://www.b4x.com/android/forum/threads/custom-view-autotextsizelabel.30642/#post177986 https://www.b4x.com/android/forum/threads/b4x-xui-accurate-text-measurement-and-drawing.92810/
Addo Well-Known Member Licensed User Longtime User May 12, 2018 #3 i have tried the following B4X: globalfontsize = "12" itmheight = Canvas1.MeasureStringHeight(msggtext, Typeface.DEFAULT, globalfontsize) Label1.TextSize = globalfontsize Label1.Text = msggtext label1.Height = itmheight but the label height does not expanded more than 36 i needed to make its height based on text content but i have failed Upvote 0
i have tried the following B4X: globalfontsize = "12" itmheight = Canvas1.MeasureStringHeight(msggtext, Typeface.DEFAULT, globalfontsize) Label1.TextSize = globalfontsize Label1.Text = msggtext label1.Height = itmheight but the label height does not expanded more than 36 i needed to make its height based on text content but i have failed
R ronell Well-Known Member Licensed User Longtime User May 12, 2018 #4 why are you using MeasureStringHeight if you want to set label based on its length? try changing your code to this B4X: itmheight = Canvas1.MeasureStringWidth(msggtext, Typeface.DEFAULT, globalfontsize) Upvote 0
why are you using MeasureStringHeight if you want to set label based on its length? try changing your code to this B4X: itmheight = Canvas1.MeasureStringWidth(msggtext, Typeface.DEFAULT, globalfontsize)