Why are these buttons misaligned in TableLayout?

I am using a table layout to arrange a few buttons. As long as I use the same font for all labels, they are correctly aligned on each line.

For some buttons, I would like to use the icons from a custom ttf font. When I use this icon, the button is a little higher, for example:

slight offset

(This image is scaled to make the problem more obvious.)

I took measurements - the buttons seem to be the same height, regardless of the font used.

Why are the buttons not aligned correctly? Does anyone have a suggestion to align them?

Thank.

Following CommonsWare advice (thanks for the quick answers!), I tried this:

final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.CENTER_VERTICAL;
row.setLayoutParams(layoutParams);

This did not work. Let's try the following comment for aligning the base.

+4
1

TableRow

:
android:baselineAligned="false"

, .

+2

All Articles