List of usage examples for android.text StaticLayout getPaint
public final TextPaint getPaint()
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
/** * Return the layout for a numbered event. Create it if not already existing *//*from w w w .ja v a 2s .co m*/ private StaticLayout getEventLayout(StaticLayout[] layouts, int i, Event event, Paint paint, Rect r) { if (i < 0 || i >= layouts.length) { return null; } StaticLayout layout = layouts[i]; // Check if we have already initialized the StaticLayout and that // the width hasn't changed (due to vertical resizing which causes // re-layout of events at min height) if (layout == null || r.width() != layout.getWidth()) { SpannableStringBuilder bob = new SpannableStringBuilder(); if (event.title != null) { // MAX - 1 since we add a space bob.append(drawTextSanitizer(event.title.toString(), MAX_EVENT_TEXT_LEN - 1)); bob.setSpan(new StyleSpan(Typeface.BOLD), 0, bob.length(), 0); bob.append(' '); } if (event.location != null) { bob.append(drawTextSanitizer(event.location.toString(), MAX_EVENT_TEXT_LEN - bob.length())); } paint.setColor(mEventTextColor); // Leave a one pixel boundary on the left and right of the rectangle for the event layout = new StaticLayout(bob, 0, bob.length(), new TextPaint(paint), r.width(), Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true, null, r.width()); layouts[i] = layout; } layout.getPaint().setAlpha(mEventsAlpha); return layout; }