Skip to main content

Custom Layouts

Brand the Diyalog SDK user interface with your own Android layouts. Your app controls the look; the SDK keeps driving the behavior (sending messages, back navigation, typing indicator, voice recording and so on).

Requires SDK 5.14.0+. Custom layouts are available from Diyalog Android SDK 5.14.0. For colors, typography and Online Help branding, see Style your SDK.

This page covers three customization surfaces:

  1. Alert Dialog: custom dialog content (and an optional theme)
  2. Chat AppBar: custom header in the chat screen toolbar
  3. Chat Input Panel: custom message composer at the bottom of the chat screen

Overview#

FeatureRegister withApplied when
Alert DialogsetAlertDialogLayoutResId(...) (+ optional setAlertDialogThemeResId(...))Any SDK confirmation / info dialog is shown
Chat AppBarsetChatAppBarLayoutResId(...)The chat screen opens
Chat Input PanelsetChatInputPanelLayoutResId(...)The chat screen opens

All setters are on DiyalogEngine.diyalogInstance().

Design principles#

  • Opt-in: if you never call a setter, the SDK uses its default UI.
  • Contract by view id: your layout must declare the same @+id/... names the SDK expects, with matching view types.
  • Safe fallback: if inflation fails or a required id or type is missing, the SDK keeps its default layout. An incomplete custom layout never crashes the chat screen.
  • Register early: call the setters in Application.onCreate() (or before opening a chat or showing a dialog), next to the rest of your Diyalog setup.

Important: partial layouts#

Validation is all-or-nothing for required ids.

Host layoutResult
All required ids present with correct typesCustom layout is applied
Any required id missing or with the wrong typeCustom layout is ignored; SDK default UI is used
Crash?No. The fallback protects the app

Example: an AppBar with only home and title (no avatar, subtitle, typing, ...) will not show your minimal bar. The SDK shows its default AppBar instead.

Quick start#

Call these once during app startup, before createDiyalog(...) or any chat navigation:

import im.diyalog.sdk.DiyalogEngine;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Optional: custom alert theme (window / dim / width)
DiyalogEngine.diyalogInstance()
.setAlertDialogThemeResId(R.style.HostAlertDialogTheme);
// Custom alert content layout
DiyalogEngine.diyalogInstance()
.setAlertDialogLayoutResId(R.layout.host_sdk_alert_dialog);
// Custom chat AppBar header
DiyalogEngine.diyalogInstance()
.setChatAppBarLayoutResId(R.layout.host_sdk_chat_appbar);
// Custom chat input (bottom send panel)
DiyalogEngine.diyalogInstance()
.setChatInputPanelLayoutResId(R.layout.host_sdk_chat_input_panel);
// ... then initialize Diyalog as usual
}
}

Disable a customization at runtime by passing 0:

DiyalogEngine.diyalogInstance().setChatAppBarLayoutResId(0);
DiyalogEngine.diyalogInstance().setChatInputPanelLayoutResId(0);
DiyalogEngine.diyalogInstance().setAlertDialogLayoutResId(0);
DiyalogEngine.diyalogInstance().setAlertDialogThemeResId(0);

The Diyalog sample app contains layouts that satisfy every contract on this page. The easiest way to start is to copy them into your app, keep the ids, and change only the styling:

  • res/layout/host_sdk_alert_dialog.xml
  • res/layout/host_sdk_chat_appbar.xml
  • res/layout/host_sdk_chat_input_panel.xml

1. Custom Alert Dialog#

Brand the confirmation and info dialogs shown by the SDK (logout, errors, permission prompts and so on) with your own colors, typography and button styles.

Alert Dialog API#

MethodDescription
setAlertDialogLayoutResId(int)Host content layout resource id (0 \= platform default dialog)
getAlertDialogLayoutResId()Current layout id
setAlertDialogThemeResId(int)Optional dialog theme / style (0 \= SDK default)
getAlertDialogThemeResId()Current theme id
DiyalogEngine.diyalogInstance().setAlertDialogThemeResId(R.style.HostAlertDialogTheme);
DiyalogEngine.diyalogInstance().setAlertDialogLayoutResId(R.layout.host_sdk_alert_dialog);

Optional theme example#

<!-- res/values/styles.xml -->
<style name="HostAlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowMinWidthMajor">90%</item>
<item name="android:windowMinWidthMinor">90%</item>
</style>

Alert Dialog required view ids#

Declare these exact ids in your layout. Id names are resolved in the host app package.

IdTypeRole
tv_alert_titleTextViewDialog title (hidden when empty)
tv_alert_messageTextViewDialog message (hidden when empty)
btn_alert_okany View (usually TextView / Button)Positive / OK action
btn_alert_cancelany ViewNegative / Cancel action
btn_alert_neutralany ViewNeutral action (required only if that dialog uses a neutral button)

Buttons that a dialog does not use are hidden by the SDK. If a dialog needs OK / Cancel and those views are missing, the SDK falls back to the platform AlertDialog.

Minimal layout skeleton#

<?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="wrap_content"
android:orientation="vertical"
android:padding="24dp">
<TextView
android:id="@+id/tv_alert_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_alert_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:textSize="16sp" />
<TextView
android:id="@+id/btn_alert_cancel"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:gravity="center"
android:clickable="true"
android:focusable="true" />
<TextView
android:id="@+id/btn_alert_ok"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="12dp"
android:gravity="center"
android:clickable="true"
android:focusable="true" />
<!-- Include only if you use neutral buttons in SDK dialogs -->
<!--
<TextView
android:id="@+id/btn_alert_neutral"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="12dp"
android:gravity="center"
android:clickable="true"
android:focusable="true" />
-->
</LinearLayout>

Alert Dialog behavior notes#

  • Title and message text are set by the SDK for each dialog.
  • If a button view is a TextView, the SDK also sets the button label.
  • Clicking a custom button runs the dialog listener and dismisses the dialog.
  • Dialogs that show a list, an adapter or other custom content do not use the host layout; they keep the standard platform dialog.

2. Custom Chat AppBar#

Replace the chat conversation header (inside the toolbar) with your own bar: back control, peer name, optional avatar, presence, typing indicator and unread badge.

Chat AppBar API#

MethodDescription
setChatAppBarLayoutResId(int)Host AppBar header layout (0 \= SDK default bar_conversation_normal)
getChatAppBarLayoutResId()Current layout id
DiyalogEngine.diyalogInstance()
.setChatAppBarLayoutResId(R.layout.host_sdk_chat_appbar);

Where the AppBar is applied#

When the chat screen sets up its toolbar, the SDK:

  1. Inflates your layout
  2. Validates the required ids and types
  3. Swaps it in place of the default header
  4. Keeps the internal id conversation_toolbar_normal, so the message-selection toolbar animation keeps working

Note: Online Help chat screens are not customized by this API. Use the Online Help style settings on Style your SDK instead.

Chat AppBar required view ids#

All ids are required. Reference layout in the SDK: bar_conversation_normal.xml.

IdRequired typeRole
homeany ViewBack / close control
counterTextViewUnread badge on the back area
titleContainerany ViewTap area that opens profile / group info
avatarPreviewim.diyalog.sdk.view.avatar.AvatarViewPeer / group avatar
titleTextViewPeer / group name
subtitleContainerany ViewContainer for subtitle and typing
typingContainerany ViewTyping indicator row
typingImageImageViewTyping animation icon
typingTextViewTyping text
subtitleTextViewPresence / member count line

subtitle can be a plain TextView or the SDK's PresenceMarqueeTextView; both work.

AppBar layout skeleton#

<?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="?attr/actionBarSize"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/ic_action_navigation_arrow_back" />
<TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:visibility="invisible" />
</FrameLayout>
<LinearLayout
android:id="@+id/titleContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<im.diyalog.sdk.view.avatar.AvatarView
android:id="@+id/avatarPreview"
android:layout_width="32dp"
android:layout_height="32dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<FrameLayout
android:id="@+id/subtitleContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/typingContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/typingImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/typing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textSize="12sp" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Chat AppBar behavior notes#

  • You own the styling (colors, sizes, margins, drawables).
  • The SDK binds name, avatar, presence, typing and counter into these ids.
  • The message-selection toolbar (forward, delete, copy, ...) is still the SDK's own and keeps sliding over your header.

Fallback example (title and back only)#

If your layout contains only home and title and omits avatar, subtitle, typing or counter:

  • The custom AppBar is not applied
  • Users see the SDK default AppBar
  • The app does not crash

To use a custom AppBar, include all required ids listed above. You can still style them freely, including making some of them visually small or hiding them yourself, but the views must exist.

3. Custom Chat Input Panel#

Replace the bottom composer (text field, send, attach, voice recording UI, reply preview and related overlays) with your own panel.

Chat Input Panel API#

MethodDescription
setChatInputPanelLayoutResId(int)Host send-panel layout (0 \= SDK default fl_send_panel)
getChatInputPanelLayoutResId()Current layout id
DiyalogEngine.diyalogInstance()
.setChatInputPanelLayoutResId(R.layout.host_sdk_chat_input_panel);

Where the input panel is applied#

When the chat screen creates its content view, the SDK:

  1. Inflates your panel
  2. Validates the required ids and types
  3. Swaps it in for the default fl_send_panel
  4. Re-assigns the id fl_send_panel, so the mentions list, share menu and audio lock hint stay positioned above the panel

Root requirement#

The root of your layout must be a LinearLayout (vertical recommended).

Chat Input Panel required view ids#

Grouped by feature area. All of these are required for the custom panel to apply, unless marked optional.

Composer (core)#

IdRequired typeRole
fl_send_panel1FrameLayoutComposer frame
et_messageEditTextMessage field
ib_attachImageButtonAttach / share menu
ib_emojiImageViewEmoji button (may stay gone)
ib_sendim.diyalog.sdk.view.TintImageViewSend button
record_btnImageViewHold-to-record microphone
rlActionButtonContainerRelativeLayoutHolds send and microphone

Reply / quote preview#

IdRequired typeRole
reply_preview_rowLinearLayoutReply preview row
quote_senderTextViewQuoted sender
quote_textTextViewQuoted text
ib_close_quoteany ViewClose reply preview
reply_preview_accentany ViewAccent strip (optional)

Voice recording#

IdRequired typeRole
audioContainerany ViewSlide-to-cancel bar
audioTimerTextViewRecording timer
audioSlideany ViewCancel hint
record_pointany ViewRecording pulse dot
audioLockedControlsany ViewLocked recording controls
audioLockedStopImageViewDelete locked recording
audioLockedSendImageViewSend locked recording
audioLockedTimerTextViewLocked recording timer

Note: The audio lock hint bubble (audioLockLayout / audioLockIcon) lives outside the send panel and is not part of your input layout.

YouTube paste preview#

IdRequired typeRole
youtubeInfoRlRelativeLayoutYouTube info row
tv_image_youtubeImageViewThumbnail
tv_title_youtubeTextViewTitle
tv_label_youtubeTextViewLabel

Kicked / not a member#

IdRequired typeRole
kickedFromChatany ViewOverlay shown when the user is not a group member
kicked_textTextViewText inside that overlay

Link preview (optional)#

IdTypeRole
linkPreviewContainerFrameLayoutLink preview container (optional)
linkPreviewViewim.diyalog.sdk.controllers.conversation.messages.linkpreview.LinkPreviewViewLink preview (optional)

Structural tips#

  • Keep send and microphone inside rlActionButtonContainer at the end / bottom of fl_send_panel1.
  • Leave horizontal room at the end of the text field for the floating button (the default layout uses about 62dp).
  • Start from the sample host_sdk_chat_input_panel.xml and restyle it, rather than building from an empty file.

Chat Input Panel behavior notes#

  • Send, attach, voice, reply and blocked / kicked flows keep working as long as the ids above exist with the correct types.
  • If validation fails, the default SDK input panel is kept (no crash).
  • The mentions list and attach menu are screen-level siblings; they are not part of your panel XML.

Integration checklist#

Common#

  • Setters are called in Application.onCreate() (or before the first chat / dialog)
  • Layout resources live in the host module (app/src/main/res/layout/...)
  • View ids use the exact names from this page (@+id/title, not @+id/tvTitle)
  • View types match the tables (especially AvatarView, TintImageView, EditText, ImageButton)

Alert Dialog#

  • tv_alert_title, tv_alert_message, btn_alert_ok, btn_alert_cancel are present
  • btn_alert_neutral is added if any flow shows a neutral button
  • Optional theme registered with setAlertDialogThemeResId
  • A known SDK dialog (for example logout) shows your branding

Chat AppBar#

  • All AppBar required ids are present
  • avatarPreview is an im.diyalog.sdk.view.avatar.AvatarView
  • Open a 1:1 and a group chat; check title, avatar, presence, typing, back and unread badge
  • Enter message selection mode; the selection toolbar still animates

Chat Input#

  • Root is a LinearLayout
  • All required composer, reply, audio, YouTube and kicked ids are present
  • ib_send is an im.diyalog.sdk.view.TintImageView
  • Test: type and send, attach, reply, hold-to-record (if enabled), group kick overlay

Troubleshooting#

SymptomLikely cause
Still see the SDK default UIA required id is missing or has the wrong type, or the setter was not called / called after the chat was already open
Inflate exception / fallbackInvalid XML, a custom view class missing from the classpath, or a bad drawable reference
Avatar crash / bind issuesavatarPreview is not an AvatarView
Send button not tinting / wrong typeib_send is not a TintImageView
Mentions / share menu overlap the inputPanel height or gravity differs from the sample; keep bottom alignment like the sample layout

API summary#

DiyalogEngine.diyalogInstance()
.setAlertDialogThemeResId(R.style.*) // optional
.setAlertDialogLayoutResId(R.layout.*) // alert content
.setChatAppBarLayoutResId(R.layout.*) // chat header
.setChatInputPanelLayoutResId(R.layout.*) // chat composer
Pass 0 to any setter to restore SDK defaults for that surface.

Default SDK layouts you can use as a reference: bar_conversation_normal.xml (chat AppBar) and activity_dialog.xml (fl_send_panel, chat input).