# MaskFilterSpan

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# MaskFilterSpan

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/text/style/MaskFilterSpan "View this page in Java")  

```
open class MaskFilterSpan : CharacterStyle, UpdateAppearance
```

|---|---|------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                            |||
| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle)     ||
|   | ↳ | [android.text.style.MaskFilterSpan](https://developer.android.com/reference/kotlin/android/text/style/MaskFilterSpan#) |

Span that allows setting a[MaskFilter](https://developer.android.com/reference/kotlin/android/graphics/MaskFilter.html#)to the text it's attached to.

For example, to blur a text, a[android.graphics.BlurMaskFilter](https://developer.android.com/reference/kotlin/android/graphics/BlurMaskFilter.html#)can be used:  

```kotlin
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

|                                                                                                                                                                                                                                Public constructors                                                                                                                                                                                                                                 ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [MaskFilterSpan](https://developer.android.com/reference/kotlin/android/text/style/MaskFilterSpan#MaskFilterSpan(android.graphics.MaskFilter))`(`filter:` `[MaskFilter](https://developer.android.com/reference/kotlin/android/graphics/MaskFilter.html#)!`)` Creates a[MaskFilterSpan](https://developer.android.com/reference/kotlin/android/text/style/MaskFilterSpan#)from a[MaskFilter](https://developer.android.com/reference/kotlin/android/graphics/MaskFilter.html#). |

|                                                                                                                                                                        Public methods                                                                                                                                                                        ||
|-----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[MaskFilter](https://developer.android.com/reference/kotlin/android/graphics/MaskFilter.html#)! | [getMaskFilter](https://developer.android.com/reference/kotlin/android/text/style/MaskFilterSpan#getMaskFilter())`()` Return the mask filter for this span.                                                                                             |
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                | [toString](https://developer.android.com/reference/kotlin/android/text/style/MaskFilterSpan#toString())`()` <br />                                                                                                                                      |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                    | [updateDrawState](https://developer.android.com/reference/kotlin/android/text/style/MaskFilterSpan#updateDrawState(android.text.TextPaint))`(`ds:` `[TextPaint](https://developer.android.com/reference/kotlin/android/text/TextPaint.html#)!`)` <br /> |

| Inherited functions ||
|---|---|
| From class[CharacterStyle](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle) |-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [CharacterStyle](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle)! | [getUnderlying](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle#getUnderlying())`()` <br /> Returns "this" for most CharacterStyles, but for CharacterStyles that were generated by[wrap](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)), returns the underlying CharacterStyle. <br />                                                                                                                                                                            | | [CharacterStyle](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle)! | [wrap](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle))`(`cs:` `[CharacterStyle](https://developer.android.com/reference/kotlin/android/text/style/CharacterStyle)!`)` <br /> 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. <br /> | ||

## Public constructors

### MaskFilterSpan

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
MaskFilterSpan(filter: MaskFilter!)
```

Creates a[MaskFilterSpan](https://developer.android.com/reference/kotlin/android/text/style/MaskFilterSpan#)from a[MaskFilter](https://developer.android.com/reference/kotlin/android/graphics/MaskFilter.html#).

|                                                                      Parameters                                                                      ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `filter` | [MaskFilter](https://developer.android.com/reference/kotlin/android/graphics/MaskFilter.html#)!:the filter to be applied to the`TextPaint` |

## Public methods

### getMaskFilter

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getMaskFilter(): MaskFilter!
```

Return the mask filter for this span.

|                                                             Return                                                             ||
|-------------------------------------------------------------------------------------------------|-------------------------------|
| [MaskFilter](https://developer.android.com/reference/kotlin/android/graphics/MaskFilter.html#)! | the mask filter for this span |

### toString

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun toString(): String
```

|                                                          Return                                                          ||
|----------------------------------------------------------------------------------|----------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |

### updateDrawState

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun updateDrawState(ds: TextPaint!): Unit
```