Skip to main content
A MessageTemplate defines and customizes both the structure and the behavior of the MessageBubble. It acts as a schema for creating message bubble components, allowing you to manage the appearance and interactions of message bubbles within your application.

When to Use This

  • Customize the header, content, footer, bottom, or status info view of a message bubble
  • Replace the default bubble layout with a completely custom view
  • Add or modify the long-press options on a message bubble
  • Create a new template for a custom message type (e.g., a contact card)
  • Change how a specific message type (text, image, etc.) renders in the MessageList

Prerequisites

  • CometChat Android UI Kit dependency added
  • CometChatUIKit.init() called and completed
  • A logged-in CometChat user
  • Familiarity with the MessageList component

Quick Start

  1. Get the list of existing message templates from the data source:
  1. Find the template for the message type you want to customize:
  1. Customize a view on the matched template:
  1. Apply the modified templates to the MessageList:

Core Concepts

MessageBubble Structure

The MessageBubble structure is broken down into these views:
  1. Leading view — Sender’s avatar. Left for incoming, right for outgoing.
  2. Header view — Sender’s name. Useful in group chats.
  3. Content view — Core message content (text, images, videos, etc.).
  4. Bottom view — Additional elements like link previews or “load more” buttons.
  5. Footer view — Timestamp and delivery/read status.

Template Properties

  • Type: setType() maps the template to a CometChatMessage type.
  • Category: setCategory() links the template with a message category.

Implementation

Header View

Customize the header area above the content view.

Content View

Customize the main content area of the message bubble.

Status Info View

Customize the status info area (delivery/read status indicators).

Bottom View

Extend the bubble with additional elements beneath the content view.
Customize the footer area (timestamp and delivery status).

Bubble View

Replace the entire message bubble with a fully custom layout.

Options

Customize the long-press action menu for a message type.

Creating a New Template

Create a template for a custom message type (e.g., a contact card):

Next Steps

Message List

Display messages in a conversation

Message Bubble Styling

Style individual bubble types

Component Styling

Detailed styling reference

View Slots

Replace specific UI regions