draw text as big as possible inside a rectangle

by Michael Bollmann » Sat, 11 Apr 2009 21:42:08 GMT


Sponsored Links
 Is there any convenient method to draw a string (custom true type
font)
as big is possible inside a supplied rectangle or to calculate the
font
size of a paint object based on a string and some rectangle
dimensions.

Thanks in advance
Michael
--~--~---------~--~----~------------~-------~--~----~



draw text as big as possible inside a rectangle

by Michael Bollmann » Tue, 14 Apr 2009 00:08:17 GMT


 thanks for your reply

in case anyone runs into the same problem i solved it using
getTextBounds

1. calculate the scale factor between your original rect and the rect
returned by getTextBounds
2. multiply the font size by this factor
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Main App & SurfaceHolder?

Hey guys, total Android noob here. :)

For my first app, I'm having a go at developing a simple video camera
app.
(There isn't one yet~!)

So I've been reading through the docs, and I've come up with a tiny
bit of code.

...Sorry if there's code tags. (I'm a mod over at another forum, I
know the rules!) ;)

Anyway, I digress.

package com.android.hello;

import android.app.Activity;
import android.os.Bundle;
import android.hardware.Camera;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Camera cam = Camera.open();
        cam.startPreview();
    }
}

I'm stuck on assigning something with cam.setPreviewDisplay();

I've looked in the docs, and come across this method. I know it takes
a SurfaceHolder as a parameter.

But I can't instantiate a SurfaceHolder object, so I'm assuming the
main app has one?

Thanks in advance,
Danny

--~--~---------~--~----~------------~-------~--~----~

2. how to get menu handler

I'd like to disable a menu item in void onCreate(Bundle
savedInstanceState).  Is there a system call to get the menu handler?
Thanks

--~--~---------~--~----~------------~-------~--~----~

3. Access point signal level updating

4. Is it possible to buy G1 developer device from Italy?

5. Compass Cals

6. Using WebView with AlertDialog

7. ACTION_ANSWER never answers the call - phone state stays RINGING..