> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-agent-in-group-react-v6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Message Composer

> Message Composer — CometChat documentation.

## Overview

MessageComposer is a [Component](/ui-kit/android/v4/components-overview#components) 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.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/1dpm1fhJnD7O18Uv/images/c99d16f0-ia31645odb8scpt02a6w4jx9vdkkqnc56vcp8g0ynubmmtus8t66ih2emsmcozx8-1b756215eda5976da0551ef849b860fd.png?fit=max&auto=format&n=1dpm1fhJnD7O18Uv&q=85&s=7dbf887093dc062f6b6188675bd5c5c1" width="1249" height="1147" data-path="images/c99d16f0-ia31645odb8scpt02a6w4jx9vdkkqnc56vcp8g0ynubmmtus8t66ih2emsmcozx8-1b756215eda5976da0551ef849b860fd.png" />
</Frame>

MessageComposer is comprised of the following [Base Components](/ui-kit/android/v4/components-overview#base-components):

| Base Components                                  | Description                                                                                                            |
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| [MessageInput](/ui-kit/android/v4/message-input) | This provides a basic layout for the contents of this component, such as the TextField and buttons                     |
| [ActionSheet](/ui-kit/android/v4/action-sheet)   | 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 your `layout.xml` file.

```python theme={null}
<com.cometchat.chatuikit.messagecomposer.CometChatMessageComposer
                android:id="@+id/composer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
```

<Warning>
  The MessageComposer is responsible for managing runtime permissions. To ensure the **ActivityResultLauncher** is properly initialized, its object should be created in the the **onCreate** state of an activity. To ensure that the composer is loaded within the fragment, it is important to make sure that the fragment is loaded in the `onCreate` state of the activity.
</Warning>

### Actions

[Actions](/ui-kit/android/v4/components-overview#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

The `OnSendButtonClick` 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.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setOnSendButtonClick(new CometChatMessageComposer.SendButtonClick() {
        @Override
        public void onClick(Context context, BaseMessage baseMessage) {
            Toast.makeText(context, "OnSendButtonClicked ..", Toast.LENGTH_SHORT).show();
        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    messageComposer.setOnSendButtonClick(object : CometChatMessageComposer.SendButtonClick {
    override fun onClick(context: Context, baseMessage: BaseMessage) {
        Toast.makeText(context, "OnSendButtonClicked ..", Toast.LENGTH_SHORT).show()
    }
    })
    ```
  </Tab>
</Tabs>

##### 2. onError

This action doesn't change the behavior of the component but rather listens for any errors that occur in the MessageList component.

<Tabs>
  <Tab title="Java">
    ```java YourActivity.java theme={null}
    messageComposer.setOnError(new OnError() {
        @Override
        public void onError(Context context, CometChatException e) {
            //Your Exception Handling code.
        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin YourActivity.kt theme={null}
    messageComposer.setOnError(object : OnError {
        override fun onError(context: Context, e: CometChatException) {
            // Your Exception Handling code.
        }
    })
    ```
  </Tab>
</Tabs>

***

### Filters

MessageComposer component does not have any available filters.

***

### Events

[Events](/ui-kit/android/v4/components-overview#events) are emitted by a `Component`. 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 the `setStyle` method.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    MessageComposerStyle messageComposerStyle = new MessageComposerStyle();
    messageComposer.setStyle(messageComposerStyle);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val messageComposerStyle = MessageComposerStyle()
    messageComposer.setStyle(messageComposerStyle)
    ```
  </Tab>
</Tabs>

The following properties are exposed by MessageComposerStyle:

| 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](http://localhost:3000/docs-beta/ui-kit/android/v4/message-input) styles.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    MessageInputStyle messageInputStyle = new MessageInputStyle();
    messageInputStyle.setBackground(Color.BLUE);
    messageInputStyle.setCornerRadius(50);
    messageComposer.setMessageInputStyle(messageInputStyle);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val messageInputStyle = MessageInputStyle()
    messageInputStyle.setBackground(Color.BLUE)
    messageInputStyle.setCornerRadius(50)
    messageComposer.setMediaRecorderStyle(mediaRecorderStyle)
    ```
  </Tab>
</Tabs>

##### 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](/ui-kit/android/v4/media-recorder) styles.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    MediaRecorderStyle mediaRecorderStyle = new MediaRecorderStyle();
    mediaRecorderStyle.setBorderColor(Color.BLACK);
    mediaRecorderStyle.setRecordedContainerColor(Color.RED);
    messageComposer.setMediaRecorderStyle(mediaRecorderStyle);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val mediaRecorderStyle = MediaRecorderStyle()
    mediaRecorderStyle.setBorderColor(Color.BLACK)
    mediaRecorderStyle.setRecordedContainerColor(Color.RED)
    messageComposer.setMediaRecorderStyle(mediaRecorderStyle)
    ```
  </Tab>
</Tabs>

***

### 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.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    CometChatMessageComposer messageComposer = findViewById(R.id.composer);
    messageComposer.hideLiveReaction(true);
    messageComposer.disableTypingEvents(true);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val messageComposer: CometChatMessageComposer = findViewById(R.id.composer)
    messageComposer.hideLiveReaction(true)
    messageComposer.disableTypingEvents(true)
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/Esb0GoP81F5eUfZq/images/9179af88-message_composer_functionality_cometchat_screens-8a78374e1f6e7d2e09515bd95f3c80b4.png?fit=max&auto=format&n=Esb0GoP81F5eUfZq&q=85&s=d0fa7a8f4df7c36ea8c057bc78edea52" width="4498" height="3120" data-path="images/9179af88-message_composer_functionality_cometchat_screens-8a78374e1f6e7d2e09515bd95f3c80b4.png" />
</Frame>

Below is a list of customizations along with corresponding code snippets

| Property                                            | Description                                                                                                                                                                                                                                     | Code                                                      |
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| **User** <Tooltip tip="Not available">🛑</Tooltip>  | Used to pass user object of which header specific details will be shown                                                                                                                                                                         | `.setUser(user)`                                          |
| **Group** <Tooltip tip="Not available">🛑</Tooltip> | 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](/ui-kit/android/v4/mentions-formatter-guide)

**Example**

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/_EL7Vq6dx_iRWqWt/images/0f71d059-composermentions-d46d794da2dbe940733fb59ba46d79e5.png?fit=max&auto=format&n=_EL7Vq6dx_iRWqWt&q=85&s=9e8bb337c4dd6d8386ac455f37c16e52" width="7980" height="6240" data-path="images/0f71d059-composermentions-d46d794da2dbe940733fb59ba46d79e5.png" />
</Frame>

<Tabs>
  <Tab title="Java">
    ```java theme={null}

    // Initialize CometChatMentionsFormatter
    CometChatMentionsFormatter mentionFormatter = new CometChatMentionsFormatter(context);

    // set style to customize composer mention text
    mentionFormatter.setComposerMentionTextStyle(new MentionTextStyle()
                .setLoggedInUserTextStyle(Typeface.defaultFromStyle(Typeface.BOLD))
                .setTextColor(Color.parseColor("#000000")));

    // This can be passed as an array of formatter in CometChatMessageComposer by using setTextFormatters method.
    List<CometChatTextFormatter> textFormatters = new ArrayList<>();
    textFormatters.add(mentionFormatter);
    messageComposer.setTextFormatters(textFormatters);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}

    // Initialize CometChatMentionsFormatter
    val mentionFormatter = CometChatMentionsFormatter(context)
    // set style to customize composer mention text
    mentionFormatter.composerMentionTextStyle = MentionTextStyle()
    .setLoggedInUserTextStyle(Typeface.defaultFromStyle(Typeface.BOLD))
    .setTextColor(Color.parseColor("#000000"))

    // This can be passed as an array of formatter in CometChatMessageComposer by using setTextFormatters method.
    val textFormatters: MutableList<CometChatTextFormatter> = ArrayList()
    textFormatters.add(mentionFormatter)
    messageComposer.setTextFormatters(textFormatters)
    ```
  </Tab>
</Tabs>

#### AttachmentOptions

By using `setAttachmentOptions()`, you can set a list of custom `MessageComposerActions` for the MessageComposer Component. This will override the existing list of `MessageComposerActions`.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setAttachmentOptions()
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    messageComposer.setAttachmentOptions()
    ```
  </Tab>
</Tabs>

**Example**

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/dvwKpKGankGygs5o/images/6b034eea-message_composer_attachment_options_cometchat_screens-19991a9f5efdd3b2a97b52c1c98f7287.png?fit=max&auto=format&n=dvwKpKGankGygs5o&q=85&s=75deaf208d1a922f092ed5317c6c3cf1" width="4498" height="3120" data-path="images/6b034eea-message_composer_attachment_options_cometchat_screens-19991a9f5efdd3b2a97b52c1c98f7287.png" />
</Frame>

In this example, we are overriding the existing MessageComposerActions List with Capture Photo, Go Live & Payments actions.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setAttachmentOptions(new Function4<Context, User, Group, HashMap<String, String>, List<CometChatMessageComposerAction>>() {
        @Override
        public List<CometChatMessageComposerAction> invoke(Context context, User user, Group group, HashMap<String, String> stringStringHashMap) {
            List<CometChatMessageComposerAction> actionList = new ArrayList<>();

            CometChatMessageComposerAction action1 =  new CometChatMessageComposerAction();
            action1.setTitle("Capture Photo");
            action1.setIcon(com.cometchat.chatuikit.R.drawable.ic_camera);
            action1.setOnClick(new OnClick() {
                @Override
                public void onClick() {
                    Toast.makeText(context, "Capture Photo option Clicked !!!", Toast.LENGTH_SHORT).show();
                }
            });
            actionList.add(action1);

            CometChatMessageComposerAction action2 =  new CometChatMessageComposerAction();
            action2.setTitle("Go Live");
            action2.setIcon(R.drawable.broadcast_camera);
            action2.setOnClick(new OnClick() {
                @Override
                public void onClick() {
                    Toast.makeText(context, "Live Option Clicked !!!", Toast.LENGTH_SHORT).show();
                }
            });
            actionList.add(action2);

            CometChatMessageComposerAction action3 =  new CometChatMessageComposerAction();
            action3.setTitle("Payments");
            action3.setIcon(R.drawable.ic_payment);
            action3.setOnClick(new OnClick() {
                @Override
                public void onClick() {
                    Toast.makeText(context, "Payment Option Clicked !!!", Toast.LENGTH_SHORT).show();
                }
            });
            actionList.add(action3);
            return actionList;
        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
        messageComposer.setAttachmentOptions { context, user, group, stringStringHashMap ->
            val actionList = ArrayList<CometChatMessageComposerAction>()

            val action1 = CometChatMessageComposerAction()
            action1.title = "Capture Photo"
            action1.icon = com.cometchat.chatuikit.R.drawable.ic_camera
            action1.onClick = {
                Toast.makeText(context, "Capture Photo option Clicked !!!", Toast.LENGTH_SHORT).show()
            }
            actionList.add(action1)

            val action2 = CometChatMessageComposerAction()
            action2.title = "Go Live"
            action2.icon = R.drawable.broadcast_camera
            action2.onClick = {
                Toast.makeText(context, "Live Option Clicked !!!", Toast.LENGTH_SHORT).show()
            }
            actionList.add(action2)

            val action3 = CometChatMessageComposerAction()
            action3.title = "Payments"
            action3.icon = R.drawable.ic_payment
            action3.onClick = {
                Toast.makeText(context, "Payment Option Clicked !!!", Toast.LENGTH_SHORT).show()
            }
            actionList.add(action3)

            actionList
        }
    ```
  </Tab>
</Tabs>

***

#### AuxiliaryButtonView

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

<Tabs>
  <Tab title="Java">
    ```java theme={null}
     messageComposer.setAuxiliaryButtonView()
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
     messageComposer.setAuxiliaryButtonView()
    ```
  </Tab>
</Tabs>

Please note that the MessageComposer Component utilizes the AuxiliaryButton to provide sticker functionality. Overriding the AuxiliaryButton will subsequently replace the sticker functionality.

**Example**

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/-aV5rjAnFmfmGI_M/images/8339c363-message_composer_auxiliary_button_cometchat_screens-cd2ac22e44e92adedd974f71cb4ba11a.png?fit=max&auto=format&n=-aV5rjAnFmfmGI_M&q=85&s=30119a4550fe248bc9b0644dc67a4124" width="4498" height="3120" data-path="images/8339c363-message_composer_auxiliary_button_cometchat_screens-cd2ac22e44e92adedd974f71cb4ba11a.png" />
</Frame>

In this example, we'll be adding a custom SOS button with click functionality. You'll first need to create a layout file and then inflate it inside the `.setAuxiliaryButtonView()` function.

```xml auxiliary_button_layout.xml theme={null}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:id="@+id/card_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="SOS !"
            android:padding="2dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>

</RelativeLayout>
```

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setAuxiliaryButtonView((context, user, group, stringStringHashMap) -> {

        View view = getLayoutInflater().inflate(R.layout.auxiliary_button_layout, null);
        CardView cardView = view.findViewById(R.id.card_button);
        cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context, "Clicked on SOS", Toast.LENGTH_SHORT).show();
            }
        });
        return view;
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    messageComposer.setAuxiliaryButtonView { context, user, group, stringStringHashMap ->
        val view: View = LayoutInflater.from(context).inflate(R.layout.auxiliary_button_layout, null)
        val cardView: CardView = view.findViewById(R.id.card_button)
        cardView.setOnClickListener {
            Toast.makeText(context, "Clicked on SOS", Toast.LENGTH_SHORT).show()
        }
        view
    }
    ```
  </Tab>
</Tabs>

***

#### SecondaryButtonView

You can add a custom view into the SecondaryButton component for additional functionality using the below method.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setSecondaryButtonView()
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    messageComposer.setSecondaryButtonView()
    ```
  </Tab>
</Tabs>

Please note that the MessageComposer Component uses the SecondaryButton to open the ComposerActionsList. Overriding the SecondaryButton will replace the ComposerActionsList functionality.

**Example**

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/BRVNF1Z1yHcA0g5c/images/3f12a282-message_composer_secondary_button_cometchat_screens-ec936ecd0df0388c121e7a58e2485e79.png?fit=max&auto=format&n=BRVNF1Z1yHcA0g5c&q=85&s=99021d8951a04d8486043da4a0aba124" width="4498" height="3120" data-path="images/3f12a282-message_composer_secondary_button_cometchat_screens-ec936ecd0df0388c121e7a58e2485e79.png" />
</Frame>

In this example, we'll be adding a custom SOS button with click functionality. You'll first need to create a layout file and then inflate it inside the `.setSecondaryButtonView()` function.

```xml secondary_button_layout.xml theme={null}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:id="@+id/card_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="SOS !"
            android:padding="2dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>

</RelativeLayout>
```

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setSecondaryButtonView((context, user, group, stringStringHashMap) -> {

        View view = getLayoutInflater().inflate(R.layout.secondary_button_layout, null);
        CardView cardView = view.findViewById(R.id.card_button);
        cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context, "Clicked on SOS", Toast.LENGTH_SHORT).show();
            }
        });
        return view;
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    messageComposer.setSecondaryButtonView { context, user, group, stringStringHashMap ->
        val view: View = LayoutInflater.from(context).inflate(R.layout.secondary_button_layout, null)
        val cardView: CardView = view.findViewById(R.id.card_button)
        cardView.setOnClickListener {
            Toast.makeText(context, "Clicked on SOS", Toast.LENGTH_SHORT).show()
        }
        view
    }
    ```
  </Tab>
</Tabs>

***

#### Set SendButtonView

You can set a custom view in place of the already existing send button view. Using the following method.

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setSendButtonView();
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    messageComposer.setSendButtonView();
    ```
  </Tab>
</Tabs>

**Example**

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/RI0xrNuukR5gbXqh/images/de49a65e-message_composer_send_button_cometchat_screens-35c85e240044565e0facc426bd90ddbf.png?fit=max&auto=format&n=RI0xrNuukR5gbXqh&q=85&s=84142f3315213118867d19a1c19f1a97" width="4498" height="3120" data-path="images/de49a65e-message_composer_send_button_cometchat_screens-35c85e240044565e0facc426bd90ddbf.png" />
</Frame>

```xml send_button_layout.xml theme={null}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:id="@+id/card_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        app:cardCornerRadius="30dp"
        >
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="15dp"
            android:src="@drawable/ic_send"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>

</RelativeLayout>
```

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    View view = getLayoutInflater().inflate(R.layout.send_button_layout, null);
    messageComposer.setSendButtonView(view);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    View view = getLayoutInflater().inflate(R.layout.send_button_layout, null);
    messageComposer.setSendButtonView(view);
    ```
  </Tab>
</Tabs>

***

#### HeaderView

You can set custom headerView to the MessageComposer component using the following method

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    messageComposer.setHeaderView();
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    messageComposer.setHeaderView();
    ```
  </Tab>
</Tabs>

**Example**

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/wITpHRGFWGJvJnmU/images/ef041808-message_composer_header_view_cometchat_screens-48ec2263937d2ccedc9979ad666d65bd.png?fit=max&auto=format&n=wITpHRGFWGJvJnmU&q=85&s=c3c744abc8c968c8903ef941ff0d95a2" width="4498" height="3120" data-path="images/ef041808-message_composer_header_view_cometchat_screens-48ec2263937d2ccedc9979ad666d65bd.png" />
</Frame>

In the following example, we're going to apply a mock smart reply view to the MessageComposer Component using the `.setHeaderView()` method.

```xml custom_header_view_layout theme={null}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical"
    android:orientation="horizontal"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:id="@+id/card1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>

    <androidx.cardview.widget.CardView
        android:id="@+id/card2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>


    <androidx.cardview.widget.CardView
        android:id="@+id/card3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>


    <androidx.cardview.widget.CardView
        android:id="@+id/card4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>

</LinearLayout>
```

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    View view = getLayoutInflater().inflate(R.layout.custom_header_view_layout, null);
    messageComposer.setHeaderView(view);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val view: View = LayoutInflater.from(context).inflate(R.layout.custom_header_view_layout, null)
    messageComposer.setHeaderView(view)
    ```
  </Tab>
</Tabs>

***

#### FooterView

You can set a custom footer view to the MessageComposer component using the following method:

<Tabs>
  <Tab title="Java">
    ```java theme={null}
     messageComposer.setFooterView();
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
     messageComposer.setFooterView();
    ```
  </Tab>
</Tabs>

**Example**

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/Kv5z_j0TcKGMfIHt/images/bdcdc69b-message_composer_footer_view_cometchat_screens-56ef7900ba38e821cdf3bab9e61e1237.png?fit=max&auto=format&n=Kv5z_j0TcKGMfIHt&q=85&s=40ff52c320421f4eb0212058c349e693" width="4498" height="3120" data-path="images/bdcdc69b-message_composer_footer_view_cometchat_screens-56ef7900ba38e821cdf3bab9e61e1237.png" />
</Frame>

In the following example, we're going to apply a mock smart reply view to the MessageComposer Component using the `.setFooterView()` method.

```xml custom_footer_view_layout theme={null}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical"
    android:orientation="horizontal"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:id="@+id/card1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>

    <androidx.cardview.widget.CardView
        android:id="@+id/card2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>


    <androidx.cardview.widget.CardView
        android:id="@+id/card3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>


    <androidx.cardview.widget.CardView
        android:id="@+id/card4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="5dp"
        app:cardCornerRadius="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Smart Reply"
            android:padding="10dp"
            android:paddingEnd="5dp"
            android:paddingStart="5dp"
            android:textColor="@color/white"
            android:background="@color/purple_700"
            />

    </androidx.cardview.widget.CardView>

</LinearLayout>
```

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    View view = getLayoutInflater().inflate(R.layout.custom_footer_view_layout, null);
    messageComposer.setHeaderView(view);
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val view: View = LayoutInflater.from(context).inflate(R.layout.custom_footer_view_layout, null)
    messageComposer.setHeaderView(view)
    ```
  </Tab>
</Tabs>

***
