IconMarginSpan
open class IconMarginSpan : LeadingMarginSpan, LineHeightSpan
Paragraph affecting span, that draws a bitmap at the beginning of a text. The span also allows setting a padding between the bitmap and the text. The default value of the padding is 0px. The span should be attached from the first character of the text.
For example, an IconMarginSpan
with a bitmap and a padding of 30px can be set like this:
SpannableString string = new SpannableString("Text with icon and padding");
string.setSpan(new IconMarginSpan(bitmap, 30), 0, string.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Text with
IconMarginSpan
Summary
Public methods |
open Unit |
|
open Unit |
drawLeadingMargin(c: Canvas!, p: Paint!, x: Int, dir: Int, top: Int, baseline: Int, bottom: Int, text: CharSequence!, start: Int, end: Int, first: Boolean, layout: Layout!)
|
open Bitmap |
Returns the bitmap to be used at the beginning of the text
|
open Int |
|
open Int |
Returns the padding width between the bitmap and the text.
|
open String |
|
Public constructors
IconMarginSpan
IconMarginSpan(bitmap: Bitmap)
Creates an IconMarginSpan
from a Bitmap
.
Parameters |
bitmap |
Bitmap: bitmap to be rendered at the beginning of the text This value cannot be null . |
IconMarginSpan
IconMarginSpan(
bitmap: Bitmap,
pad: Int)
Creates an IconMarginSpan
from a Bitmap
.
Parameters |
bitmap |
Bitmap: bitmap to be rendered at the beginning of the text This value cannot be null . |
pad |
Int: padding width, in pixels, between the bitmap and the text Value is 0 or greater |
Public methods
drawLeadingMargin
open fun drawLeadingMargin(
c: Canvas!,
p: Paint!,
x: Int,
dir: Int,
top: Int,
baseline: Int,
bottom: Int,
text: CharSequence!,
start: Int,
end: Int,
first: Boolean,
layout: Layout!
): Unit
Parameters |
c |
Canvas!: the canvas |
p |
Paint!: the paint. The this should be left unchanged on exit. |
x |
Int: the current position of the margin |
dir |
Int: the base direction of the paragraph; if negative, the margin is to the right of the text, otherwise it is to the left. |
top |
Int: the top of the line |
baseline |
Int: the baseline of the line |
bottom |
Int: the bottom of the line |
text |
CharSequence!: the text |
start |
Int: the start of the line |
end |
Int: the end of the line |
first |
Boolean: true if this is the first line of its paragraph |
layout |
Layout!: the layout containing this line |
getBitmap
open fun getBitmap(): Bitmap
Returns the bitmap to be used at the beginning of the text
Return |
Bitmap |
a bitmap This value cannot be null . |
getLeadingMargin
open fun getLeadingMargin(first: Boolean): Int
Parameters |
first |
Boolean: true if the request is for the first line of a paragraph, false for subsequent lines |
Return |
Int |
the offset for the margin. |
getPadding
open fun getPadding(): Int
Returns the padding width between the bitmap and the text.
The units of this value are pixels.
Return |
Int |
a padding width in pixels The units of this value are pixels. {} |
toString
open fun toString(): String
Return |
String |
a string representation of the object. |