Centering text in a button?

by CyberQat » Wed, 11 Nov 2009 03:42:30 GMT

Sponsored Links
 Hi Guys,

Ive just started fooling around with programming my Motorola Droid.
I'm programmatic ally laying out an interface such that the text
contained in my Button is sized at layout time to fit the button.  My
questions are:

(1) I know the pixel size of the button, what is the best way to set
the text size to fit the button size?
(2) I can't seem to get it to center.  I've tried a Gravity of 11 and
that helps, but ist still not right.  How do I get my text to center
itself properly horizontally and vertically in the button?



Centering text in a button?

by CyberQat » Thu, 12 Nov 2009 14:19:22 GMT

 Some more info

The text is perfectly centered (but tiny) if I lave it at the default
setting.  If I try to scale it
up to match the button size however I lose vertical centering :(

Ive tried looking at the drawing code but it is massively complex.

Anyone know a soln?


Sponsored Links

Other Threads

1. What Cancels Timer and TimerTasks?

I'm trying to write an egg timer application.  Here's what I have:

* An Activity that has the UI for adding timer and displaying time
* A Service that has a Timer/TimerTask which controls the countdown

When I set a really long time, say nine hours and go to bed, somewhere
in the night something cancels the timer. According the the
Applications menu the app is still "running" and the Running Services
shows that the Service is still running, but the Timer is no longer
sending "ticks." I've put Logs all over every function to see if
something's getting called, but nothing does!

What cancels Timer/TimerTasks? How do you keep them running in

I've tried using a partial WakeLock, but it failed.



2. google analytics and active installs on market way off


I got an application that on shows around 
20k active installs / 30k total installs. However, google analytics for the 
app (that's not really doing anything weird. It's just using the normal api, 
collecting fairly standard data). Is showing 100k+ unique visitors since 
launch (around 37k so far this month).

What should I trust?


3. Moving gif android

4. bitmap image from a SurfaceView

5. Free gesture library

6. Live Wallpaper Memory Allocation

7. Couldn't refresh list