[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-27。"],[],[],null,["# Emoji Picker\n\nThe Emoji Picker is a UI solution that offers a modern look and feel, up-to-date\nemoji, and ease of use. Users can browse and select emoji and their variants\nor choose from their recently-used emoji.\n**Figure 1.** Emoji Picker\n\nWith this library, apps from a variety of sources can provide an inclusive and\nunified emoji experience to their users without developers having to build and\nmaintain their own emoji picker from scratch.\n\nFeatures\n--------\n\nThe Emoji Picker has the following features.\n\n### Up-to-date emoji\n\nNewly-released emoji are selectively included in the Emoji Picker. The Emoji\nPicker library is compatible across multiple Android versions and devices.\n\n### Sticky variants\n\nLong-press an emoji to display a menu of variants, such as different genders or\nskin tones. The variant you choose is saved in the Emoji Picker, and the last\nselected variant is used in the main panel.\n\nWith this feature, users can send their preferred emoji variants with one tap.\n**Figure 2.** Emoji variants.\n\n### Recent emoji\n\n**Figure 3.** Recent emoji.\n\nThe `RecentEmojiProvider` is responsible for providing emoji in the\n**Recently Used** category. The library has a default recent emoji provider\nthat satisfies the most common use case:\n\n- All selected emoji are saved per-app in shared preferences.\n- The picker displays at most three rows of selected emoji, deduped, in reverse chronological order.\n\nIf this default behavior is sufficient, then you don't need to use\n`setRecentEmojiProvider()`.\n\nYou might need to customize the provider behavior, however. Here are some common\nscenarios:\n\n- You want to store different selected emoji per user account.\n- You want to use data storage other than shared preferences.\n- You want to display recent emoji sorted by frequency.\n\nYou can then implement the `RecentEmojiProvider` interface and set it using\n`setRecentEmojiProvider()`.\n\n### Direction selector\n\nStarting with [Emoji 15.1](https://emojipedia.org/emoji-15.1), the Emoji Picker supports\nbidirectional emoji. Users can tap on the bidirectional switcher to toggle\nbetween left- and right-facing versions of emoji.\n\n**Figure 4.** Bidirectional emoji facing left.\n\n**Figure 5.** Bidirectional emoji facing right.\n\n### Multi-person emoji selector\n\nUsers can touch and hold emoji couples to reveal multi-person emoji selections.\n\n**Figure 6.** Touch and hold an emoji couple to reveal multi-person emoji\nselections.\n\n**Figure 7.** Select a left-half emoji person.\n\n**Figure 8.** Select a right-half emoji person.\n\nWhen the user selects the left- or right-half emoji person of an emoji couple,\nthe selector displays a preview on the bottom-right, as shown in figures 7 and\n8. After selecting both halves of the emoji couple, users can select the preview\nto compose the custom emoji couple.\n\n### Compatibility with `EmojiCompat`\n\nIf enabled, an `EmojiCompat` instance is used in the Emoji Picker to render as\nmany emoji as possible. The Emoji Picker doesn't require `EmojiCompat`, however.\n\nPrerequisites\n-------------\n\nYour app must target Android 5.0 (API level 21) or higher.\n\nUse the library\n---------------\n\n1. Import `androidx.emoji2:emojipicker:$version` in your app's `build.gradle`\n file.\n\n dependencies {\n implementation \"androidx.emoji2:emojipicker:$version\"\n }\n\n2. Inflate the Emoji Picker view, and optionally set `emojiGridRows` and\n `emojiGridColumns`.\n\n - The default number of `emojiGridColumns` is 9.\n - Row count is calculated based on the parent view height and the value of `emojiGridColumns`.\n - Use a float value for `emojiGridRows` to indicate that the user can scroll for more emoji.\n\n \u003candroidx.emoji2.emojipicker.EmojiPickerView\n android:id=\"@+id/emoji_picker\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n app:emojiGridColumns=\"9\" /\u003e\n\n val emojiPickerView = EmojiPickerView(context).apply {\n emojiGridColumns = 15\n layoutParams = ViewGroup.LayoutParams(\n ViewGroup.LayoutParams.MATCH_PARENT,\n ViewGroup.LayoutParams.MATCH_PARENT\n )\n }\n\n findViewById\u003cViewGroup\u003e(R.id.emoji_picker_layout).addView(emojiPickerView)\n\n3. Use `setOnEmojiPickedListener()` to append the selected emoji to a view.\n For example, to append to an `EditText`, do the following:\n\n emojiPickerView.setOnEmojiPickedListener {\n findViewById\u003cEditText\u003e(R.id.edit_text).append(it.emoji)\n }\n\n4. Optionally set `RecentEmojiProvider`, see sample app for an example\n implementation.\n\n5. Optionally customize styles. Create your own style to override common theme\n attributes and apply the style to the `EmojiPickerView`. For example,\n overriding `colorControlNormal` changes the category icon color.\n\n \u003cstyle name=\"CustomStyle\" \u003e\n \u003citem name=\"colorControlNormal\"\u003e#FFC0CB\u003c/item\u003e\n \u003c/style\u003e\n \u003candroidx.emoji2.emojipicker.EmojiPickerView\n android:id=\"@+id/emoji_picker\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:theme=\"@style/CustomStyle\"\n app:emojiGridColumns=\"9\" /\u003e\n\nSample App\n----------\n\nThe [Emoji Picker sample app](https://github.com/androidx/androidx/tree/androidx-main/emoji2/emoji2-emojipicker/samples) demonstrates basic use cases along with\nthe following additional scenarios:\n\n- Layout recalculation when `emojiGridRows` or `emojiGridColumns` are reset.\n- An overridden recent emoji provider that sorts by frequency.\n- Additional style customization."]]