Best code examples for Android StaticLayout class (android.text.StaticLayout)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android StaticLayout class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android StaticLayout examples from Open Source projects
This code example shows how to use the following methods: draw, getLineCount
	private int getTextLineCount(CharSequence source, TextPaint paint, int widthPx, float textSize) {
		// Update the text paint object 
		paint.setTextSize(textSize);
 
		// Draw using a static layout 
		StaticLayout layout = new StaticLayout(source, paint, widthPx, Alignment.ALIGN_NORMAL, mSpacingMult,
				mSpacingAdd, true);
		layout.draw(TEXT_RESIZE_CANVAS);
 
		return layout.getLineCount();
	} 
} 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineBounds, getWidth
This code example shows how to use the following methods: getLineEnd, getLineCount
 
    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;
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHeight
 
        // Layout the text. 
        int outerWidth = right - config.mTitleLeft;
        String title = mTitle;
        mTitleLayout = new StaticLayout(title, 0, title.length(), config.mPaint, outerWidth, Layout.Alignment.ALIGN_NORMAL, 1, 0,
                true, TextUtils.TruncateAt.MIDDLE, outerWidth);
        mTitleY = top + (height - mTitleLayout.getHeight()) / 2;
    } 
 
    public static final class Config { 
        private final int mIconLeft;
        private final int mTitleLeft;
        private final int mIconSize;
        private final TextPaint mPaint;
 
        public Config(int iconSpan, int iconSize, TextPaint paint) {
            mIconLeft = (iconSpan - iconSize) / 2;
            mTitleLeft = iconSpan;
            mIconSize = iconSize;
            mPaint = paint;
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight
	// Set the text size of the text paint object and use a static layout to render text off screen before measuring 
	private int getTextRect(CharSequence source, TextPaint paint, int width, float textSize) {
		// Update the text paint object 
		paint.setTextSize(textSize);
		// Draw using a static layout 
		StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, spacingMult, spacingAdd, false);
		layout.draw(textResizeCanvas);
		return layout.getHeight();
	} 
} 
Full Snippet Info
6
CodeRank
Related Android StaticLayout Questions & Answers:
See Code Examples for Android StaticLayout Methods: