Maodge Member Licensed User May 25, 2018 #1 Hi, in my project , i set button text property as Attached File designer setting.png "center_horizontal,center_vertical" and script Code: Copy btnMusicTuneMid.Width=15%x btnMusicTuneMid.Height=40dip btnMusicTuneMid.Top=355dip btnMusicTuneMid.Left=67%x btnMusicTuneMid.TextSize=22 but part of the text is not displayed,and the text is not center_vertical. there some place at the top of button. And how to solve this problem ? Thanks Attachments 20180525170410.jpg 241.3 KB · Views: 685 designer setting.png 146.5 KB · Views: 740
Hi, in my project , i set button text property as Attached File designer setting.png "center_horizontal,center_vertical" and script Code: Copy btnMusicTuneMid.Width=15%x btnMusicTuneMid.Height=40dip btnMusicTuneMid.Top=355dip btnMusicTuneMid.Left=67%x btnMusicTuneMid.TextSize=22 but part of the text is not displayed,and the text is not center_vertical. there some place at the top of button. And how to solve this problem ? Thanks
klaus Expert Licensed User Longtime User May 25, 2018 #2 What padding values do you have? The text size is probably too big for the button height. Upvote 0
Maodge Member Licensed User May 25, 2018 #3 klaus said: What padding values do you have? The text size is probably too big for the button height. Click to expand... device details: 720 X 1280, scale = 2 (320 dpi) And could you give some suggestions about how to determine the size of the text? Thanks a lot Upvote 0
klaus said: What padding values do you have? The text size is probably too big for the button height. Click to expand... device details: 720 X 1280, scale = 2 (320 dpi) And could you give some suggestions about how to determine the size of the text? Thanks a lot
klaus Expert Licensed User Longtime User May 25, 2018 #4 It is possible to calculate the text height with the MeasureMultilineTextHeight method from the StringUtils library. Then you need to know the Padding of the view, which are are extra spaces arround the text. Additionnally, buttons with the default background are smaller than the external dimensions. Attached a small test project showing the differences. The upper button is a 'standard' button with a height of 40dip and a text size of 22, your case. The second button has a Padding of 0, 0, 0, 0. The third button has a 'standard' color background, with the full dimensions. Attachments ButtonTextSize.zip ButtonTextSize.zip 9.2 KB · Views: 560 Upvote 0
It is possible to calculate the text height with the MeasureMultilineTextHeight method from the StringUtils library. Then you need to know the Padding of the view, which are are extra spaces arround the text. Additionnally, buttons with the default background are smaller than the external dimensions. Attached a small test project showing the differences. The upper button is a 'standard' button with a height of 40dip and a text size of 22, your case. The second button has a Padding of 0, 0, 0, 0. The third button has a 'standard' color background, with the full dimensions.