Bug 1331431 - Use baseline and FontMetrics instead of textview's center and text size to get the real text height. r?sebastian
MozReview-Commit-ID: 4HJKZP0F0ow
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FadedMultiColorTextView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FadedMultiColorTextView.java
@@ -49,22 +49,23 @@ public class FadedMultiColorTextView ext
final boolean needsEllipsis = needsEllipsis();
if (needsEllipsis) {
final int right = getWidth() - getCompoundPaddingRight();
final float left = right - fadeWidth;
updateGradientShader(needsEllipsis, right);
- final float center = getHeight() / 2;
-
// Shrink height of gradient to prevent it overlaying parent view border.
// The shrunk size just nee to cover the text itself.
- final float top = center - getTextSize() / 2;
- final float bottom = center + getTextSize() / 2;
+ final float density = getResources().getDisplayMetrics().density;
+ final float h = Math.abs(fadePaint.getFontMetrics().top) + 1;
+ final float l = fadePaint.getFontMetrics().bottom + 1;
+ final float top = getBaseline() - h * density;
+ final float bottom = getBaseline() + l * density;
canvas.drawRect(left, top, right, bottom, fadePaint);
}
}
private void updateGradientShader(final boolean needsEllipsis, final int gradientEndRight) {
final int backgroundColor =
fadeBackgroundColorList.getColorForState(getDrawableState(), Color.RED);