How to get String width

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to get String width

Postby c3r13e12u5 » Wed Oct 29, 2008 3:28 am

How can i get how many pixels will be used to draw a String on the canvas?
in J2ME we can use Font.stringWidth(String s). how about in Android?
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Top

Postby c3r13e12u5 » Tue Nov 04, 2008 2:07 am

Finally got the code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Paint p = new Paint();
  2.  
  3. p.measureText("Test Measure Text");
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 5 guests