Example usage for android.text Layout getLineDescent

List of usage examples for android.text Layout getLineDescent

Introduction

In this page you can find the example usage for android.text Layout getLineDescent.

Prototype

public abstract int getLineDescent(int line);

Source Link

Document

Return the descent of the specified line(0…getLineCount() - 1).

Usage

From source file:com.android.ex.chips.RecipientEditTextView.java

private MoreImageSpan createMoreSpan(final int count) {
    final String moreText = String.format(mMoreItem.getText().toString(), count);
    final TextPaint morePaint = new TextPaint(getPaint());
    morePaint.setTextSize(mMoreItem.getTextSize());
    morePaint.setColor(mMoreItem.getCurrentTextColor());
    final int width = (int) morePaint.measureText(moreText) + mMoreItem.getPaddingLeft()
            + mMoreItem.getPaddingRight();
    final int height = getLineHeight();
    final Bitmap drawable = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(drawable);
    int adjustedHeight = height;
    final Layout layout = getLayout();
    if (layout != null)
        adjustedHeight -= layout.getLineDescent(0);
    canvas.drawText(moreText, 0, moreText.length(), 0, adjustedHeight, morePaint);
    final Drawable result = new BitmapDrawable(getResources(), drawable);
    result.setBounds(0, 0, width, height);
    return new MoreImageSpan(result);
}