If you have the paint
paint.measureText works pretty well :)

- Dan

On Fri, Sep 4, 2009 at 9:19 AM, Shaka <[email protected]> wrote:

>
> Dunno if this is the best way to do it but I do it like this.
>
> Rect bounds = new Rect();
> textPaint.getTextBounds(string, 0, string.length(), bounds);
> return bounds.width();
>
> On 4 Sep, 00:25, hap 497 <[email protected]> wrote:
> > Thank you. But how can i specify a certain TextAppearance before
> > calling Paint.getTextWidths()?
> >
> > On Thu, Sep 3, 2009 at 3:19 PM, greg<[email protected]> wrote:
> >
> > > Have you read about Paint.getTextWidths()?
> >
> > > On Sep 3, 5:15 pm, hap 497 <[email protected]> wrote:
> > >> Hi,
> >
> > >> Is there any api to find out the width of a string when rendered using
> > >> a certain text appearance?
> >
> > >> For example, I want to find out how long is the width if I render a
> > >> string 'hello world'  using "?android:attr/textAppearanceLargeInverse"
> > >> programatically in Java Code.
> >
> > >> Thank you.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to