Questions tagged [staticlayout]

An Android text layout class for laying out text that will not change.

The Android documentation is here.

If the text will change then a DynamicLayout is used.

41 questions
1
vote
1 answer

How to reduce StaticLayout delay when using long text

I use StaticLayout to paginate my text to create an epub application, and I have a text that has 16,000 lines. The StaticLayout object is created about 6 seconds later and it's very slow. How can I reduce this time or is there another way to use…
1
vote
1 answer

Measuring tight bounds box of multiline text

I'm drawing a multiline text on a canvas using StaticLayout, and I want to measure the most tight bounds box around the text before drawing, (the text could be in different sizes, fonts, styles etc...), I want something like that: Size…
Roi Amiel
  • 353
  • 1
  • 3
  • 18
1
vote
1 answer

StaticLayout positioning center of canvas not working like canvas.drawText?

While drawing with usual drawText the text is positioning to the center of canvas. But my requirment is to place multiline text, so I've to use StaticLayout, but StaticLayout is not getting placed like drawText Here's what I've tried so far. class…
1
vote
0 answers

android.text.html (fromHtml): render inline CSS colors

I have a text like this: Test which is given to Html.fromHtml call, which returns a Spanned used in a StaticLayout drawn on an Android Canvas bound to a Bitmap. The image which is drawn contains this bold text.…
JarsOfJam-Scheduler
  • 2,809
  • 3
  • 31
  • 70
1
vote
1 answer

Android - Draw Text At The Bottom Of A Bitmap Using Static Layout

I have the following code that puts some text at the top of an image: val paint = TextPaint(Paint.ANTI_ALIAS_FLAG) paint.color = Color.WHITE paint.textSize = 40f //* context.resources.displayMetrics.density paint.typeface =…
Foobar
  • 7,458
  • 16
  • 81
  • 161
1
vote
0 answers

How to use specified paragraph spacing with StaticLayout in Android

I have a long text which has multiple paragraph in it. But I want to use specified (eventually more than line spacing value) paragraph spacing between two paragraph in the text. Here I am using StaticLayout and drawing on canvas. As there is no…
Sainik
  • 165
  • 1
  • 3
  • 9
1
vote
1 answer

Android Layout: meaning of getLineBaseline, getLineDescent, getLineAscent, getLineBottom, getLineTop

The documentation for the following methods of Layout (including StaticLayout, DynamicLayout, and BoringLayout) are very sparce. getLineBaseline(int line) getLineDescent(int line) getLineAscent(int line) getLineBottom(int line) getLineTop(int…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
1
vote
0 answers

How TextSize and LineSpace affects ImageSpan

I want to measure ImageSpan with StaticLayout. to do this I use a simple code like below: SpannableStringBuilder content = new SpannableStringBuilder(); Spannable imageSpannable = getImageSpannable(); content.append(imageSpannable); StaticLayout…
Hojjat
  • 815
  • 1
  • 10
  • 25
1
vote
0 answers

Draw Cursor in Custom View using StaticLayout (multiline)

If I have: new StaticLayout(text, paint, width, alignment, 1.0f, 0.0f, false); How to draw Cursor in text?
0
votes
0 answers

LinearLayout does not respond to child height change in RecyclerView

I'm trying to achieve a expandable textview which allow user to expand our collapse text longer than specified lines. However, when the text is expanded, requestLayout of the TextView was called, but LinearLayout instead of expanding itself, it cut…
0
votes
0 answers

How to set Padding for text in StaticLayout Android?

I want to set padding for text created using StaticLayout in Android I can't set padding for text and text is cut off when using font and using alignment example
Exception
  • 3
  • 2
0
votes
1 answer

How to draw text in multiple line in multiple pages using static layout for PDF Creation

I am using below code to draw text and write in PDF, but it is not able to draw in multiple pages? What would be the best approach for this problem. PdfDocument document = new PdfDocument(); PdfDocument.PageInfo pageInfo = new …
Jasmine John
  • 873
  • 8
  • 12
0
votes
1 answer

How to add background color for staticLayout in Android

I want to add background color for below staticLayout background color as transperentblock to appear text clearly can some one help me how can i achieve this Code public static Bitmap drawMultilineTextToBitmap(Context gContext, Bitmap bitmap,…
Krish
  • 4,166
  • 11
  • 58
  • 110
0
votes
0 answers

Reduce StaticLayout initialize time for text over 16,000 lines

I use StaticLayout to paginate my text to create an epub application and i have a text that has 16,000 lines. The StaticLayout object is created about 6 seconds later and it's very slow. How can I reduce this time or is there another way to use…
0
votes
0 answers

Can we know if text exceeds the boundary of StaticLayout horizontally for single line text and vertically for multiline text

I have drawn one StaticLayout on imageview and I have to write single as well as multiline text. Issue is I have to restrict the user if text crosses the horizontal boundary in case of single line and also restrict the user vertically in case of…
Ravi Yadav
  • 2,296
  • 3
  • 25
  • 32