I am a UX architect working with a team of Android developers that are mostly junior. We are having issues properly setting line height in Android.
We are using the
Here's a way to do it programatically.
public static void setLineHeight(TextView textView, int lineHeight) {
int fontHeight = textView.getPaint().getFontMetricsInt(null);
textView.setLineSpacing(dpToPixel(lineHeight) - fontHeight, 1);
}
public static int dpToPixel(float dp) {
DisplayMetrics metrics = getResources().getDisplayMetrics();
float px = dp * (metrics.densityDpi / 160f);
return (int) px;
}