BulletSpan
open class BulletSpan : LeadingMarginSpan, ParcelableSpan
kotlin.Any | |
↳ | android.text.style.BulletSpan |
A span which styles paragraphs as bullet points (respecting layout direction).
BulletSpans must be attached from the first character to the last character of a single paragraph, otherwise the bullet point will not be displayed but the first paragraph encountered will have a leading margin.
BulletSpans allow configuring the following elements:
- gap width - the distance, in pixels, between the bullet point and the paragraph. Default value is 2px.
- color - the bullet point color. By default, the bullet point color is 0 - no color, so it uses the TextView's text color.
- bullet radius - the radius, in pixels, of the bullet point. Default value is 4px.
<code>SpannableString string = new SpannableString("Text with\nBullet point"); string.setSpan(new BulletSpan(), 10, 22, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);</code>
To construct a BulletSpan with a gap width of 40px, green bullet point and bullet radius of 20px:
<code>SpannableString string = new SpannableString("Text with\nBullet point"); string.setSpan(new BulletSpan(40, color, 20), 10, 22, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);</code>
Summary
Constants | |
---|---|
static Int |
Public constructors | |
---|---|
Creates a |
|
BulletSpan(gapWidth: Int) Creates a |
|
BulletSpan(gapWidth: Int, color: Int) Creates a |
|
BulletSpan(gapWidth: Int, color: Int, bulletRadius: Int) Creates a |
|
BulletSpan(src: Parcel) Creates a |
Public methods | |
---|---|
open Int | |
open Unit |
drawLeadingMargin(canvas: Canvas, paint: 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 Int |
Get the radius, in pixels, of the bullet point. |
open Int |
getColor() Get the bullet point color. |
open Int |
Get the distance, in pixels, between the bullet point and the paragraph. |
open Int |
getLeadingMargin(first: Boolean) |
open Int | |
open String |
toString() |
open Unit |
writeToParcel(dest: Parcel, flags: Int) Flatten this object in to a Parcel. |
Constants
Public constructors
BulletSpan
BulletSpan(gapWidth: Int)
Creates a BulletSpan
based on a gap width
Parameters | |
---|---|
gapWidth |
Int: the distance, in pixels, between the bullet point and the paragraph. |
BulletSpan
BulletSpan(
gapWidth: Int,
color: Int)
Creates a BulletSpan
based on a gap width and a color integer.
Parameters | |
---|---|
gapWidth |
Int: the distance, in pixels, between the bullet point and the paragraph. |
color |
Int: the bullet point color, as a color integer |
See Also
BulletSpan
BulletSpan(
gapWidth: Int,
color: Int,
bulletRadius: Int)
Creates a BulletSpan
based on a gap width and a color integer.
Parameters | |
---|---|
gapWidth |
Int: the distance, in pixels, between the bullet point and the paragraph. |
color |
Int: the bullet point color, as a color integer. |
bulletRadius |
Int: the radius of the bullet point, in pixels. Value is 0 or greater |
See Also
BulletSpan
BulletSpan(src: Parcel)
Creates a BulletSpan
from a parcel.
Parameters | |
---|---|
src |
Parcel: This value cannot be null . |
Public methods
describeContents
open fun describeContents(): Int
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
drawLeadingMargin
open fun drawLeadingMargin(
canvas: Canvas,
paint: 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 |
the canvas |
p |
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: This value cannot be null . |
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?: This value may be null . |
canvas |
Canvas: This value cannot be null . |
paint |
Paint: This value cannot be null . |
getBulletRadius
open fun getBulletRadius(): Int
Get the radius, in pixels, of the bullet point.
Return | |
---|---|
Int |
the radius, in pixels, of the bullet point. |
getColor
open fun getColor(): Int
Get the bullet point color.
Return | |
---|---|
Int |
the bullet point color |
getGapWidth
open fun getGapWidth(): Int
Get the distance, in pixels, between the bullet point and the paragraph.
Return | |
---|---|
Int |
the distance, in pixels, between the bullet point and the paragraph. |
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. |
toString
open fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
open fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel: This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |