how to obtain the default font size

by guich » Wed, 16 Mar 2011 01:39:54 GMT


Sponsored Links
 Hi,

I searched the topics and tried some things, but could not achieve
what i need.

I want to obtain the font height in PIXELS used in the text "Silent
mode" of the "Sound & display" option of the Settings application.

In this screen i see lots of font sizes, but i want the biggest size.
I assume that this is the standard size of the font for the device.

Actually, if i could find any "default font size" in pixels i could
compute the other sizes.

What i have is:

1. A class that extends SurfaceView
1.1 A Bitmap that's drawn with my app contents
1.2 A SurfaceHolder
2. A class that extends Activity

I assumed that i could get the info with some structure at the
surfaceChanged, but i checked all methods of all classes and could not
find anything useful.

TIA,

     guich

-- 



Re: how to obtain the default font size

by Brill Pappin » Wed, 16 Mar 2011 03:36:36 GMT


 I'm interested in what responses you get.

I attempted to use text sizes indicated by the OS in one of my keyboards, 
but it turns out that some phones don't report it properly or have a very 
different idea of what the size means than others do. For me the result was 
that on some phones the text would be very tiny.
So far I have not discovered a really reliable way to set a text size.

- Brill Pappin

-- 


Sponsored Links


Re: how to obtain the default font size

by guich » Wed, 16 Mar 2011 21:05:28 GMT


 Its really a shame that this can't be done. I never found a solution,
in any other threads. Boy, i miss Windows Mobile, with their
SystemMetrics api.

guich

-- 



Re: Re: how to obtain the default font size

by Pepijn Van Eeckhoudt » Wed, 16 Mar 2011 21:27:46 GMT


 

Its really a shame that this can't be done. I never found a solution, in any other threads. Boy, i miss Windows Mobile, with their SystemMetrics api.
Have you tried reuse the correct style/theme ( http://developer.android.com/guide/topics/ui/themes.html )? Bit of a kludge, but you could also try creating an instance of the corresponding View and asking that for its text size. (e.g., new TextView().getTextSize()) Pepijn --



Re: how to obtain the default font size

by guich » Wed, 16 Mar 2011 22:06:07 GMT


 Pepijn,

Many thanks. That simple line solved the issue.

Got the following results:

Htc Magic: 14
Motorola Spice: 11
Motorola Milestone: 21

So, from this i can achieve the results i need.

All the best

    guich

-- 



Re: how to obtain the default font size

by guich » Wed, 16 Mar 2011 22:07:39 GMT


 Many thanks, it worked!

-- 



Other Threads

1. On click enlarge the image

Hi All,

I have a textview and an imagebutton.

textview has the description about the image[which is there in imagebutton]

Now on clickin the image button i want the imagebutton to occupy the whole
screen and on clicking this i want the imagebutton back to normal position

plz help ...

-- 

2. Quick logcat question

I fear the answer is no, but before I change the structure of all of
my log messages:

Is there any way to do this:
$ adb logcat *:S com.myappname.*:V

Or in words: I want to silence every tag that goes to logcat except
the ones that begin with com.myappname. Currently my classes print
into the log with this.getClass().getName() as the tag - typing each
tag out individually in the filter isn't an option, so is there anyway
to use the wildcard?

The above command doesn't work, because it just silences every class,
including the ones I've explicitly told to be verbal.
I've also tried:

$ adb logcat -s com.myappname.*:V
$ adb logcat com.myappname.*:V *:S

to no avail.

I have a feeling I might have to log in a more constant fashion. Or I
might just use log4J.
Any help/suggestions appreciated - perhaps you use a static log class?

Let me know,
Cheers,
~redders

-- 

3. Accessing a Web Based Google Map from within an Android Application

4. Speex support?

5. Conditional compile and porting techniques.

6. HTTP "Bad Request" when Posting File data to HTTPS from Phone But Not Emulator

7. Tabbed UI