3

Possible Duplicate:
How do I center text horizontally and vertical in a TextView in Android?

I want to set the text in the center of textview (vertical and horizontal) . it is horizontally centered by vertical it has more space in the top of the text.

xml layout :

    <TextView
        android:id="@+id/txtQuantity"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center|center_vertical"
        android:text="+"
        android:textColor="@color/white"
        android:textSize="25sp" />
</LinearLayout>
Community
  • 1
  • 1
Adham
  • 63,550
  • 98
  • 229
  • 344

1 Answers1

7

Use android:gravity="center" instead of android:gravity="center|center_vertical".

This will center it both horizontally and vertically.

prolink007
  • 33,872
  • 24
  • 117
  • 185