IconMarginSpan
open class IconMarginSpan : LeadingMarginSpan, LineHeightSpan
| kotlin.Any | |
| ↳ | android.text.style.IconMarginSpan |
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);
IconMarginSpan
Summary
| Public constructors | |
|---|---|
IconMarginSpan(bitmap: Bitmap)Creates an |
|
IconMarginSpan(bitmap: Bitmap, pad: Int)Creates an |
|
| Public methods | |
|---|---|
| open Unit |
chooseHeight(text: CharSequence!, start: Int, end: Int, istartv: Int, v: Int, fm: Paint.FontMetricsInt!)Classes that implement this should define how the height is being calculated. |
| 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!)Renders the leading margin. |
| open Bitmap |
Returns the bitmap to be used at the beginning of the text |
| open Int |
getLeadingMargin(first: Boolean)Returns the amount by which to adjust the leading margin. |
| open Int |
Returns the padding width between the bitmap and the text. |
| open String |
toString()Returns a string representation of the object. |
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
chooseHeight
open fun chooseHeight(
text: CharSequence!,
start: Int,
end: Int,
istartv: Int,
v: Int,
fm: Paint.FontMetricsInt!
): Unit
Classes that implement this should define how the height is being calculated.
| Parameters | |
|---|---|
text |
CharSequence!: the text |
start |
Int: the start of the line |
end |
Int: the end of the line |
spanstartv |
the start of the span |
lineHeight |
the line height |
fm |
Paint.FontMetricsInt!: font metrics of the paint, in integers |
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
Renders the leading margin. This is called before the margin has been adjusted by the value returned by getLeadingMargin(boolean).
| 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
Returns the amount by which to adjust the leading margin. Positive values move away from the leading edge of the paragraph, negative values move towards it.
| 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
Returns a string representation of the object.
| Return | |
|---|---|
String |
a string representation of the object. |