Overview
MessageComposer is a Component that enables users to write and send a variety of messages, including text, image, video, and custom messages. Features such as Live Reaction, Attachments, and Message Editing are also supported by it.
| Base Components | Description |
|---|---|
| MessageInput | This provides a basic layout for the contents of this component, such as the TextField and buttons |
| ActionSheet | The ActionSheet component presents a list of options in either a list or grid mode, depending on the user’s preference |
Usage
Integration
The following code snippet illustrates how you can directly incorporate the MessageComposer component into yourlayout.xml file.
Actions
Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.1. OnSendButtonClick
TheOnSendButtonClick event gets activated when the send message button is clicked. It has a predefined function of sending messages entered in the composer EditText. However, you can overide this action with the following code snippet.
- Java
- Kotlin
2. onError
This action doesn’t change the behavior of the component but rather listens for any errors that occur in the MessageList component.- Java
- Kotlin
YourActivity.java
Filters
MessageComposer component does not have any available filters.Events
Events are emitted by aComponent. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.
The MessageComposer Component does not emit any events of its own.
Customization
To fit your app’s design requirements, you can customize the appearance of the MessageComposer component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.Style
Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.1. MessageComposer Style
To modify the styling, you can apply the MessageComposerStyle to the MessageComposer Component using thesetStyle method.
- Java
- Kotlin
| Property | Description | Code |
|---|---|---|
| Set BorderWidth | Used to set outermost border | .setBorderWidth(int) |
| Border Color | Used to set border color | .setBorderColor(@ColorInt int) |
| Corner Radius | Used to set corner radius | .setCornerRadius(int) |
| Background | This method will set the background color for message list | .setBackground(@ColorInt int) |
| Set InputBackgroundColor | Used to set input background color | .setInputBackgroundColor(@ColorInt int) |
| Set TextAppearance | Used to set input text style | .setTextAppearance(@StyleRes int) |
| Set PlaceHolderTextColor | Used to set placeholder text color | .setPlaceHolderTextColor(@StyleRes int) |
| Background | This will set drawable component for list background | .setBackground(@drawable int) |
| Set AttachIconTint | Used to set attachment icon tint | .setAttachIconTint(@ColorRes int) |
| Set SendIconTint | Used to set send button icon tint | .setSendIconTint(@ColorRes int) |
| Set SeparatorTint | Used to set separator color | .setSeparatorTint(@ColorRes int) |
| Set VoiceRecordingIconTint | used to set voice recording icon color | .setVoiceRecordingIconTint(@ColorRes int) |
2. MessageInput Style
To customize the styles of the MessageInput component within the MessageComposer Component, use the.setMessageInputStyle() method. For more details, please refer to MessageInput styles.
- Java
- Kotlin
3. MediaRecorder Style
To customize the styles of the MediaRecorder component within the MessageComposer Component, use the.setMediaRecorderStyle() method. For more details, please refer to MediaRecorder styles.
- Java
- Kotlin
Functionality
These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.- Java
- Kotlin

| Property | Description | Code |
|---|---|---|
| User | Used to pass user object of which header specific details will be shown | .setUser(user) |
| Group | Used to pass group object of which header specific details will be shown | .setGroup(Group) |
| Set PlaceHolderText | Used to set composer’s placeholder text | .setPlaceHolderText("Your_Text") |
| Disable TypingEvents | Used to disable/enable typing events , default false | .disableTypingEvents(boolean) |
| Disable SoundForMessages | Used to toggle sound for outgoing messages | .disableSoundForMessages(boolean) |
| Set SendButtonIcon | Used to set send button icon | .setSendButtonIcon(@DrawableRes int) |
| Set Text | Used to set predefined text | .setText("Your_Text") |
| Set MaxLine | Maximum lines allowed to increase in the input field | .setMaxLine(int) |
| Set VoiceRecordingIcon | Sets custom drawable resources for the record buttons. | .setVoiceRecordingIcon(@DrawableRes int) |
| Set VoiceRecordingVisibility | The visibility constant for the voice recording view. Use View.VISIBLE, View.INVISIBLE or View.GONE. | .setVoiceRecordingVisibility(int) |
| Set PauseIcon | Sets custom drawable resources for the pause buttons. | .setPauseIcon(@DrawableRes int) |
| Set PlayIcon | Sets custom drawable resources for the play buttons. | .setPlayIcon(@DrawableRes int) |
| Set DeleteIcon | Sets custom drawable resources for the delete buttons. | .setDeleteIcon(@DrawableRes int) |
| Set StopIcon | Sets custom drawable resources for the stop buttons. | .setStopIcon(@DrawableRes int) |
| Set AuxiliaryButtonAlignment | controls position auxiliary button view , can be left or right . default right | .setAuxiliaryButtonAlignment(AuxiliaryButtonsAlignment) |
| Set AttachmentIcon | sets the icon to show in the attachment button | .setAttachmentIcon(@DrawableRes int) |
| Hide LiveReaction | used to toggle visibility for live reaction component | .hideLiveReaction(boolean) |
| Disable Mentions | Sets whether mentions in text should be disabled. Processes the text formatters If there are text formatters available and the disableMentions flag is set to true, it removes any formatters that are instances of CometChatMentionsFormatter. | .setDisableMentions(true); |
| Set CustomSoundForMessages | Used to give custom sounds to outgoing messages | .setCustomSoundForMessages(String) |
| Set LiveReactionIcon | used to set custom live reaction icon. | .setLiveReactionIcon(@DrawableRes int) |
Advanced
For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.setTextFormatters
Assigns the list of text formatters. If the provided list is not null, it sets the list. Otherwise, it assigns the default text formatters retrieved from the data source. To configure the existing Mentions look and feel check out CometChatMentionsFormatter Example
- Java
- Kotlin
AttachmentOptions
By usingsetAttachmentOptions(), you can set a list of custom MessageComposerActions for the MessageComposer Component. This will override the existing list of MessageComposerActions.
- Java
- Kotlin

- Java
- Kotlin
AuxiliaryButtonView
You can insert a custom view into the MessageComposer component to add additional functionality using the following method.- Java
- Kotlin

.setAuxiliaryButtonView() function.
auxiliary_button_layout.xml
- Java
- Kotlin
SecondaryButtonView
You can add a custom view into the SecondaryButton component for additional functionality using the below method.- Java
- Kotlin

.setSecondaryButtonView() function.
secondary_button_layout.xml
- Java
- Kotlin
Set SendButtonView
You can set a custom view in place of the already existing send button view. Using the following method.- Java
- Kotlin

send_button_layout.xml
- Java
- Kotlin
HeaderView
You can set custom headerView to the MessageComposer component using the following method- Java
- Kotlin

.setHeaderView() method.
custom_header_view_layout
- Java
- Kotlin
FooterView
You can set a custom footer view to the MessageComposer component using the following method:- Java
- Kotlin

.setFooterView() method.
custom_footer_view_layout
- Java
- Kotlin