button text not getting centered vertically in button button text not getting centered vertically in button xml xml

button text not getting centered vertically in button


android:layout_gravity defines layout alignment inside it's parent. To align text within the button you need android:gravity, for example

<Button     ...    android:gravity="center"    ...></Button>


Your button is too short to fit the text properly. Increase the layout_height and the text should be centered.


Your text likely has some padding built into the font as part of each letter, and that is why your text is being pushed in one direction. Set the layout_height to "wrap_content" and your text should now be centered correctly.