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. Cant Send picture message(mms)from one emulator to another in Android

can any one help how to send mms in android


2. "When" are the overlays drawn on the map?

What I am trying to do - I am continuously getting a stream of lat/lng
positions, I want to move a overlay item dynamically on the map based
on the lat/lng in the stream. I am displaying the location of moving
object dynamically on the map

I am putting my whole code in a while(true) loop and trying to read
the stream every 5 seconds and refresh the overlays on the map. But
overlay items are not shown until the function (either oncreate, or
any onclickeventhandler etc) is completed. For example, test code,  I
am adding a single test overlay item when ever the user clicks on a
button. If I put a wait(2000000) "after" I add overlays and invalidate
the map, the overlay is not displayed until the time has elapsed and
the function is completed.

Any ideas or suggestions? please let me know if you want me to explain
the problem more


3. getApplication().openOrCreateDatabase causes method undefined error

4. How does AdMob calculate how much to pay developers per click? Is AdMob better than AdSense?

5. Eclipse Helios ADT plugin

6. Problem item in AlertDialog

7. Android 2.2 and falshplayer 10.1 development help