DWQA QuestionsCategory: DatabaseWhen the height of the control is close to the font size, why can't the text of Android button control be vertically centered?
peyogoat asked 1 month ago

Using the button control of Android, the size of the text and the height of the button are almost the same. If you want the text in the button to be centered in the vertical direction, how to set it?
Button is set as follows in the layout file


The layout that contains it is


Of course, I tried to put it in LinearLayout, or when I was looking for solutions online, I said that relativelayout could be used to solve the problem. However, after trying, I found that the problem was still the same.
It is shown as follows:
The font is never centered, but away from the top edge of the button control.
Guess if the button control limits the minimum value of paddingtop? How to realize the text in button to be centered vertically?

1 Answers
Gods who eat mountain ghosts answered 1 month ago

The front end also has such a problem, which is caused by the font itself, which is caused by the uneven ascending and descending parts of the font in Android system