Click here to Skip to main content
Sign Up to vote bad
good
See more: JavaAndroid
Need for some ui layout manipulations. Is this possible and how? Please help.
EDIT: If I know text size.
Posted 27 Dec '12 - 10:27
halabella1.3K
Edited 27 Dec '12 - 23:49

Comments
Sergey Alexandrovich Kryukov - 27 Dec '12 - 17:27
Wow! —SA
TorstenH. - 28 Dec '12 - 5:58
WHY? what are you trying to do? I expect you to be doing something wrong, so please share some more info about why you want to determine the length of a text.

2 solutions

string sta = "Hi This is Word";
Font arialBold = new Font("Garamond", 11.5F);
Size st1 = TextRenderer.MeasureText(sta, arialBold);
float pixcel = st1.Width;
  Permalink  
Comments
halabella - 29 Dec '12 - 13:45
Excellent!
You are looking in wrong direction. By their nature, strings do not have lengths in in pixels or something like that. Strings are data structures totally abstracted from the way they are presented, such as fonts, colors, rendering styles, geometrical sizes, etc. Those are all some properties of some UI elements, whatever they are.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 206
1 Richard MacCutchan 145
2 Tadit Dash 140
3 Sergey Alexandrovich Kryukov 135
4 Santhosh G_ 125
0 Sergey Alexandrovich Kryukov 10,294
1 OriginalGriff 7,955
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,159


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid