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

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

Android Layout examples from Open Source projects
This code example shows how to use the following methods: setColor, setShadowLayer, setTextSize, setTypeface, getDesiredWidth
277:	valuePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG 
-
281:	valuePaint.setTextSize(textSize); 
282:	valuePaint.setShadowLayer(0.5f, 0, 0.5f, 0xFFFFFFFF); 
283:	valuePaint.setTypeface(typeface); 
284:	valuePaint.setColor((textColor == NOVAL) ? ITEMS_TEXT_COLOR : textColor); 
-
448:	labelWidth = (int) FloatMath.ceil(Layout.getDesiredWidth(label, valuePaint)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAlpha, setAntiAlias, setTextSize, setTypeface, getDesiredWidth
131:	float desiredWidth = Layout.getDesiredWidth(text, paint); 
-
163:	paint = new TextPaint(); 
-
167:	paint.setTypeface(typeface); 
-
170:	paint.setTextSize(fontSize); 
-
172:	paint.setAntiAlias(true); 
173:	paint.setAlpha(255); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
45:	int line = layout.getLineForVertical(y); 
46:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: draw, getLineCount
168:	StaticLayout layout = new StaticLayout(source, paint, widthPx, Alignment.ALIGN_NORMAL, mSpacingMult, 
-
170:	layout.draw(TEXT_RESIZE_CANVAS); 
-
172:	return layout.getLineCount(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getEllipsizedWidth, getHeight
420:	canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getEllipsizedWidth() / 2, 
421:	(switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2); 
422:	switchText.draw(canvas); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getHeight, getWidth
256:	final int minWidth = Math.max(mOnLayout.getWidth(), mOffLayout.getWidth()) 
-
258:	final int minHeight = Math.max(mOnLayout.getHeight(), mOffLayout.getHeight()) 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: draw, getHeight, getWidth
583:	canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2); 
584:	switchText.draw(canvas); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
91:	int line = layout.getLineForVertical(y); 
92:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getLineEnd, getLineCount
338:	mCoordinates.subjectWidth, Alignment.ALIGN_NORMAL, 1, 0, false /* includePad */); 
339:	if (mCoordinates.subjectLineCount < mSubjectLayout.getLineCount()) { 
-
341:	int end = mSubjectLayout.getLineEnd(mCoordinates.subjectLineCount - 1); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHeight
107:	true, TextUtils.TruncateAt.MIDDLE, outerWidth); 
108:	mTitleY = top + (height - mTitleLayout.getHeight()) / 2; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight
313:	StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, spacingMult, spacingAdd, false); 
314:	layout.draw(textResizeCanvas); 
315:	return layout.getHeight(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineCount
123:	Layout layout = new StaticLayout(getText(), mTextPaintOutline, measureWidth(widthMeasureSpec), Layout.Alignment.ALIGN_CENTER, mSpacingMult, mSpacingAdd, mIncludePad); 
-
125:	setMeasuredDimension(measureWidth(widthMeasureSpec) + ex, measureHeight(heightMeasureSpec) * layout.getLineCount() + ex); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight, getWidth
246:	layout.draw( canvas ); 
-
261:	RectF rect = new RectF( -margin, -margin, layout.getWidth() + margin * 2, layout.getHeight() + margin * 2 ); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getHeight, getWidth
256:	final int minWidth = Math.max(mOnLayout.getWidth(), mOffLayout.getWidth()) 
-
258:	final int minHeight = Math.max(mOnLayout.getHeight(), mOffLayout.getHeight()) 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getTypeface, setFakeBoldText, setTextSkewX, setTypeface, getDesiredWidth
269:	if (mTextPaint.getTypeface() != tf) { 
270:	mTextPaint.setTypeface(tf); 
-
295:	mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0); 
296:	mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0); 
-
357:	float desired = Layout.getDesiredWidth(mText, mTextPaint); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
209:	int line = layout.getLineForVertical(y); 
210:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getHeight
306:	StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true); 
307:	return layout.getHeight(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight
199:	StaticLayout layout = new StaticLayout(source, paint, width, 
-
201:	layout.draw(sTextResizeCanvas); 
202:	return layout.getHeight(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
44:	int line = layout.getLineForVertical(y); 
45:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: draw, getHeight, getWidth
785:	canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2); 
786:	switchText.draw(canvas); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHeight, getWidth
127:	int textX = point.x > screenWidth / 2 ? point.x - marginX - textLayout.getWidth() : point.x + marginX; 
128:	int textY = point.y > screenHeight / 2 ? point.y - marginY - textLayout.getHeight() : point.y + marginY; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: restore, rotate, save, translate, draw
40:	canvas.save(); 
-
42:	canvas.translate(0, getHeight()); 
43:	canvas.rotate(-90); 
-
46:	getLayout().draw(canvas); 
47:	canvas.restore(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
251:	int line = layout.getLineForVertical(y); 
252:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight
200:	StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true); 
201:	layout.draw(sTextResizeCanvas); 
202:	return layout.getHeight(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineCount, getLineEnd
103:	if (layout.getLineCount() > maxLines) { 
104:	workingText = workingText.subSequence(0, layout.getLineEnd(maxLines - 1)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getLineBaseline, getWidth
46:	DynamicLayout dl = new DynamicLayout("Sharemore", sm, getWidth(), Alignment.ALIGN_NORMAL, 0.f, 0.f, true); 
-
57:	Rect r = new Rect(10,10,dl.getWidth()-10,getHeight()-10); 
-
62:	int titleB = dl.getLineBaseline(0)+10; 
-
75:	dl.draw(canvas); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight, getWidth
119:	StaticLayout layout = new StaticLayout(percent + "%", tp, m_width * 2 / 3, 
-
122:	canvas.translate((m_width - layout.getWidth()) / 2, (m_height - layout.getHeight()) / 2); 
123:	layout.draw(canvas); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getLineBaseline, getWidth
46:	DynamicLayout dl = new DynamicLayout("Sharemore", sm, getWidth(), Alignment.ALIGN_NORMAL, 0.f, 0.f, true); 
-
57:	Rect r = new Rect(10,10,dl.getWidth()-10,getHeight()-10); 
-
62:	int titleB = dl.getLineBaseline(0)+10; 
-
75:	dl.draw(canvas); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight, getWidth
90:	StaticLayout layout  = new StaticLayout(message, txtP, this.getWidth() - rpad,Layout.Alignment.ALIGN_NORMAL, 1.3f, 0, false); 
-
93:	layout.getHeight() + 
-
98:	this.setLayoutParams(new LayoutParams(this.getWidth(), layout.getHeight() + 
-
126:	layout.draw(canvas); 
-
129:	canvas.drawBitmap(picture, layout.getWidth()/2 - picture.getWidth()/2, layout.getHeight(), msgP); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getHeight
107:	true, TextUtils.TruncateAt.MIDDLE, outerWidth); 
108:	mTitleY = top + (height - mTitleLayout.getHeight()) / 2; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
45:	int line = layout.getLineForVertical(y); 
46:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight, getWidth
155:	Alignment.ALIGN_NORMAL, 1, 1, true); 
156:	text = Bitmap.createBitmap(titleLayout.getWidth(), 
157:	titleLayout.getHeight(), Bitmap.Config.ARGB_8888); 
-
159:	titleLayout.draw(textC); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: draw, getHeight
612:	StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false); 
613:	layout.draw(sTextResizeCanvas); 
614:	return layout.getHeight(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getHeight, getWidth
33:	super(layout.getWidth(), layout.getHeight()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
47:	int line = layout.getLineForVertical(y); 
48:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: draw, getHeight, getWidth
228:	(thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, 
-
230:	- switchText.getHeight() / 2); 
231:	switchText.draw(canvas); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
54:	int line = layout.getLineForVertical(y); 
55:	int off = layout.getOffsetForHorizontal(line, x); 
Full Snippet Info
6
CodeRank
Related Android Layout Questions & Answers:
See Code Examples for Android Layout Methods: