Base span class for the emoji replacement. When an emoji is found and needs to be replaced in a
CharSequence, an instance of this class is added to the CharSequence.
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,["# EmojiSpan\n\nadded in [version 26.1.0](/topic/libraries/support-library/revisions) \nbelongs to Maven artifact com.android.support:support-emoji:28.0.0-alpha1 \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nEmojiSpan\n=========\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\n\n\nabstract\nclass\nEmojiSpan\n`\n\n\n`\n\n\n`\n\n`\n\n\n`\n\n`\n\n\n`\n\n`\n\nextends `[ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html)`\n\n\n`\n\n`\n\n\n`\n\n|---|---|---|---|--------------------------------------|\n| java.lang.Object |||||\n| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) ||||\n| | ↳ | [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) |||\n| | | ↳ | [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html) ||\n| | | | ↳ | android.support.text.emoji.EmojiSpan |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nBase span class for the emoji replacement. When an emoji is found and needs to be replaced in a\nCharSequence, an instance of this class is added to the CharSequence.\n\nSummary\n-------\n\n| ### Public methods ||\n|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` int` | ` `[getSize](/reference/android/support/text/emoji/EmojiSpan#getSize(android.graphics.Paint, java.lang.CharSequence, int, int, android.graphics.Paint.FontMetricsInt))`(`[Paint](https://developer.android.com/reference/android/graphics/Paint.html)` paint, CharSequence text, int start, int end, `[Paint.FontMetricsInt](https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt.html)` fm) ` |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan.html)` ` |------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` draw(`[Canvas](https://developer.android.com/reference/android/graphics/Canvas.html)` arg0, CharSequence arg1, int arg2, int arg3, float arg4, int arg5, int arg6, int arg7, `[Paint](https://developer.android.com/reference/android/graphics/Paint.html)` arg8) ` | | ` abstract int` | ` getSize(`[Paint](https://developer.android.com/reference/android/graphics/Paint.html)` arg0, CharSequence arg1, int arg2, int arg3, `[Paint.FontMetricsInt](https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt.html)` arg4) ` | | ` void` | ` updateDrawState(`[TextPaint](https://developer.android.com/reference/android/text/TextPaint.html)` arg0) ` | | ` void` | ` updateMeasureState(`[TextPaint](https://developer.android.com/reference/android/text/TextPaint.html)` arg0) ` | ||\n| From class ` `[android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html)` ` |-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| | ` `[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) | ` getUnderlying() ` | | ` abstract void` | ` updateMeasureState(`[TextPaint](https://developer.android.com/reference/android/text/TextPaint.html)` arg0) ` | ||\n| From class ` `[android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html)` ` |------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------| | ` `[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) | ` getUnderlying() ` | | ` abstract void` | ` updateDrawState(`[TextPaint](https://developer.android.com/reference/android/text/TextPaint.html)` arg0) ` | | ` static `[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) | ` wrap(`[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html)` arg0) ` | ||\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nPublic methods\n--------------\n\n### getSize\n\nadded in [version 26.1.0](/topic/libraries/support-library/revisions) \n\n```\nint getSize (Paint paint, \n CharSequence text, \n int start, \n int end, \n Paint.FontMetricsInt fm)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|-------------------------------|\n| `paint` | `Paint` \u003cbr /\u003e |\n| `text` | `CharSequence` \u003cbr /\u003e |\n| `start` | `int` \u003cbr /\u003e |\n| `end` | `int` \u003cbr /\u003e |\n| `fm` | `Paint.FontMetricsInt` \u003cbr /\u003e |\n\n| Returns ||\n|-------|--------|\n| `int` | \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [EmojiCompat.MetadataRepoLoader](/reference/android/support/text/emoji/EmojiCompat.MetadataRepoLoader)\n-\n\n Classes\n -------\n\n - [EmojiCompat](/reference/android/support/text/emoji/EmojiCompat)\n - [EmojiCompat.Config](/reference/android/support/text/emoji/EmojiCompat.Config)\n - [EmojiCompat.InitCallback](/reference/android/support/text/emoji/EmojiCompat.InitCallback)\n - [EmojiCompat.MetadataRepoLoaderCallback](/reference/android/support/text/emoji/EmojiCompat.MetadataRepoLoaderCallback)\n - [EmojiSpan](/reference/android/support/text/emoji/EmojiSpan)\n - [FontRequestEmojiCompatConfig](/reference/android/support/text/emoji/FontRequestEmojiCompatConfig)\n - [FontRequestEmojiCompatConfig.ExponentialBackoffRetryPolicy](/reference/android/support/text/emoji/FontRequestEmojiCompatConfig.ExponentialBackoffRetryPolicy)\n - [FontRequestEmojiCompatConfig.RetryPolicy](/reference/android/support/text/emoji/FontRequestEmojiCompatConfig.RetryPolicy)\n - [MetadataRepo](/reference/android/support/text/emoji/MetadataRepo)\n - [R](/reference/android/support/text/emoji/R)\n - [R.attr](/reference/android/support/text/emoji/R.attr)\n - [R.bool](/reference/android/support/text/emoji/R.bool)\n - [R.color](/reference/android/support/text/emoji/R.color)\n - [R.dimen](/reference/android/support/text/emoji/R.dimen)\n - [R.drawable](/reference/android/support/text/emoji/R.drawable)\n - [R.id](/reference/android/support/text/emoji/R.id)\n - [R.integer](/reference/android/support/text/emoji/R.integer)\n - [R.layout](/reference/android/support/text/emoji/R.layout)\n - [R.string](/reference/android/support/text/emoji/R.string)\n - [R.style](/reference/android/support/text/emoji/R.style)\n - [R.styleable](/reference/android/support/text/emoji/R.styleable)"]]