Code example for TextPaint

Methods: ellipsize, setColor, setTextSize

0
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        } 
    } 
 
    private void calculateDrawingData() { 
        sDefaultPaint.setTextSize(mCoordinates.subjectFontSize);
        calculateSubjectText(); 
        mSubjectLayout = new StaticLayout(mText, sDefaultPaint,
                mCoordinates.subjectWidth, Alignment.ALIGN_NORMAL, 1, 0, false /* includePad */);
        if (mCoordinates.subjectLineCount < mSubjectLayout.getLineCount()) {
            // TODO: ellipsize. 
            int end = mSubjectLayout.getLineEnd(mCoordinates.subjectLineCount - 1);
            mSubjectLayout = new StaticLayout(mText.subSequence(0, end),
                    sDefaultPaint, mCoordinates.subjectWidth, Alignment.ALIGN_NORMAL, 1, 0, true);
        } 
 
        // Now, format the sender for its width 
        TextPaint senderPaint = mRead ? sDefaultPaint : sBoldPaint;
        // And get the ellipsized string for the calculated width 
        if (TextUtils.isEmpty(mSender)) {
            mFormattedSender = "";
        } else { 
            int senderWidth = mCoordinates.sendersWidth;
            senderPaint.setTextSize(mCoordinates.sendersFontSize);
            senderPaint.setColor(getFontColor(mRead ? SENDERS_TEXT_COLOR_READ
                    : SENDERS_TEXT_COLOR_UNREAD));
            mFormattedSender = TextUtils.ellipsize(mSender, senderPaint, senderWidth,
                    TruncateAt.END);
        } 
    } 
    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {