Stay organized with collections
Save and categorize content based on your preferences.
MaskFilterSpan
open class MaskFilterSpan : CharacterStyle, UpdateAppearance
Span that allows setting a MaskFilter
to the text it's attached to.
For example, to blur a text, a android.graphics.BlurMaskFilter
can be used:
MaskFilter blurMask = new BlurMaskFilter(5f, BlurMaskFilter.Blur.NORMAL);
SpannableString string = new SpannableString("Text with blur mask");
string.setSpan(new MaskFilterSpan(blurMask), 10, 15, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Text blurred with the
MaskFilterSpan
.
Summary
Inherited functions |
From class CharacterStyle
CharacterStyle! |
getUnderlying()
Returns "this" for most CharacterStyles, but for CharacterStyles that were generated by wrap , returns the underlying CharacterStyle.
|
CharacterStyle! |
wrap(cs: CharacterStyle!)
A given CharacterStyle can only applied to a single region of a given Spanned. If you need to attach the same CharacterStyle to multiple regions, you can use this method to wrap it with a new object that will have the same effect but be a distinct object so that it can also be attached without conflict.
|
|
Public constructors
Public methods
getMaskFilter
open fun getMaskFilter(): MaskFilter!
Return the mask filter for this span.
toString
open fun toString(): String
Return |
String |
a string representation of the object. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# MaskFilterSpan\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nMaskFilterSpan\n==============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/style/MaskFilterSpan \"View this page in Java\") \n\n```\nopen class MaskFilterSpan : CharacterStyle, UpdateAppearance\n```\n\n|---|---|----------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [android.text.style.CharacterStyle](/reference/kotlin/android/text/style/CharacterStyle) ||\n| | ↳ | [android.text.style.MaskFilterSpan](#) |\n\nSpan that allows setting a [MaskFilter](../../graphics/MaskFilter.html#) to the text it's attached to.\n\nFor example, to blur a text, a [android.graphics.BlurMaskFilter](../../graphics/BlurMaskFilter.html#) can be used: \n\n```kotlin\nMaskFilter blurMask = new BlurMaskFilter(5f, BlurMaskFilter.Blur.NORMAL);\n SpannableString string = new SpannableString(\"Text with blur mask\");\n string.setSpan(new MaskFilterSpan(blurMask), 10, 15, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);\n \n```\nText blurred with the `MaskFilterSpan`.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [MaskFilterSpan](#MaskFilterSpan(android.graphics.MaskFilter))`(`filter:` `[MaskFilter](../../graphics/MaskFilter.html#)!`)` Creates a [MaskFilterSpan](#) from a [MaskFilter](../../graphics/MaskFilter.html#). |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|\n| open [MaskFilter](../../graphics/MaskFilter.html#)! | [getMaskFilter](#getMaskFilter())`()` Return the mask filter for this span. |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` \u003cbr /\u003e |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [updateDrawState](#updateDrawState(android.text.TextPaint))`(`ds:` `[TextPaint](../TextPaint.html#)!`)` \u003cbr /\u003e |\n\n| Inherited functions ||\n|---|---|\n| From class [CharacterStyle](/reference/kotlin/android/text/style/CharacterStyle) |------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [CharacterStyle](/reference/kotlin/android/text/style/CharacterStyle)! | [getUnderlying](/reference/kotlin/android/text/style/CharacterStyle#getUnderlying())`()` Returns \"this\" for most CharacterStyles, but for CharacterStyles that were generated by [wrap](/reference/kotlin/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)), returns the underlying CharacterStyle. \u003cbr /\u003e | | [CharacterStyle](/reference/kotlin/android/text/style/CharacterStyle)! | [wrap](/reference/kotlin/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle))`(`cs:` `[CharacterStyle](/reference/kotlin/android/text/style/CharacterStyle)!`)` A given CharacterStyle can only applied to a single region of a given Spanned. If you need to attach the same CharacterStyle to multiple regions, you can use this method to wrap it with a new object that will have the same effect but be a distinct object so that it can also be attached without conflict. \u003cbr /\u003e | ||\n\nPublic constructors\n-------------------\n\n### MaskFilterSpan\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nMaskFilterSpan(filter: MaskFilter!)\n```\n\nCreates a [MaskFilterSpan](#) from a [MaskFilter](../../graphics/MaskFilter.html#).\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------|\n| `filter` | [MaskFilter](../../graphics/MaskFilter.html#)!: the filter to be applied to the `TextPaint` |\n\nPublic methods\n--------------\n\n### getMaskFilter\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getMaskFilter(): MaskFilter!\n```\n\nReturn the mask filter for this span.\n\n| Return ||\n|------------------------------------------------|-------------------------------|\n| [MaskFilter](../../graphics/MaskFilter.html#)! | the mask filter for this span |\n\n### toString\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun toString(): String\n```\n\n| Return ||\n|----------------------------------------------------------------------------------|----------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |\n\n### updateDrawState\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun updateDrawState(ds: TextPaint!): Unit\n```"]]