4

I have a TextView. I want to set its background color. But the color fills more top space than it does bottom space.

<!-- red background. -->
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="14sp"
    android:textStyle="bold"
    android:background="#f00"
    android:text="10.0" />

This is how it renders (zoomed in to demonstrate, green lines added by me):

enter image description here

So the extra space up top makes it look like the text is not centered within its own container. Is this expected? I'd like the text to appear vertically centered within its own container (the red area).

This is on a galaxy nexus, stock version of jellybean.

Thanks

user291701
  • 38,411
  • 72
  • 187
  • 285
  • If in appwidget, take a look at http://stackoverflow.com/questions/10629249/unexpected-button-padding-on-ics/20135309#20135309 – Evi Song Nov 22 '13 at 01:43

1 Answers1

11

Add the following attribute:

android:includeFontPadding="false"
Flávio Faria
  • 6,575
  • 3
  • 39
  • 59