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:
- Alert Dialog: custom dialog content (and an optional theme)
- Chat AppBar: custom header in the chat screen toolbar
- Chat Input Panel: custom message composer at the bottom of the chat screen
Overview#
| Feature | Register with | Applied when |
|---|---|---|
| Alert Dialog | setAlertDialogLayoutResId(...) (+ optional setAlertDialogThemeResId(...)) | Any SDK confirmation / info dialog is shown |
| Chat AppBar | setChatAppBarLayoutResId(...) | The chat screen opens |
| Chat Input Panel | setChatInputPanelLayoutResId(...) | 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 layout | Result |
|---|---|
| All required ids present with correct types | Custom layout is applied |
| Any required id missing or with the wrong type | Custom 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:
Disable a customization at runtime by passing 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.xmlres/layout/host_sdk_chat_appbar.xmlres/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#
| Method | Description |
|---|---|
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 |
Optional theme example#
Alert Dialog required view ids#
Declare these exact ids in your layout. Id names are resolved in the host app package.
| Id | Type | Role |
|---|---|---|
tv_alert_title | TextView | Dialog title (hidden when empty) |
tv_alert_message | TextView | Dialog message (hidden when empty) |
btn_alert_ok | any View (usually TextView / Button) | Positive / OK action |
btn_alert_cancel | any View | Negative / Cancel action |
btn_alert_neutral | any View | Neutral 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#
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#
| Method | Description |
|---|---|
setChatAppBarLayoutResId(int) | Host AppBar header layout (0 \= SDK default bar_conversation_normal) |
getChatAppBarLayoutResId() | Current layout id |
Where the AppBar is applied#
When the chat screen sets up its toolbar, the SDK:
- Inflates your layout
- Validates the required ids and types
- Swaps it in place of the default header
- 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.
| Id | Required type | Role |
|---|---|---|
home | any View | Back / close control |
counter | TextView | Unread badge on the back area |
titleContainer | any View | Tap area that opens profile / group info |
avatarPreview | im.diyalog.sdk.view.avatar.AvatarView | Peer / group avatar |
title | TextView | Peer / group name |
subtitleContainer | any View | Container for subtitle and typing |
typingContainer | any View | Typing indicator row |
typingImage | ImageView | Typing animation icon |
typing | TextView | Typing text |
subtitle | TextView | Presence / member count line |
subtitle can be a plain TextView or the SDK's PresenceMarqueeTextView; both work.
AppBar layout skeleton#
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#
| Method | Description |
|---|---|
setChatInputPanelLayoutResId(int) | Host send-panel layout (0 \= SDK default fl_send_panel) |
getChatInputPanelLayoutResId() | Current layout id |
Where the input panel is applied#
When the chat screen creates its content view, the SDK:
- Inflates your panel
- Validates the required ids and types
- Swaps it in for the default
fl_send_panel - 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)#
| Id | Required type | Role |
|---|---|---|
fl_send_panel1 | FrameLayout | Composer frame |
et_message | EditText | Message field |
ib_attach | ImageButton | Attach / share menu |
ib_emoji | ImageView | Emoji button (may stay gone) |
ib_send | im.diyalog.sdk.view.TintImageView | Send button |
record_btn | ImageView | Hold-to-record microphone |
rlActionButtonContainer | RelativeLayout | Holds send and microphone |
Reply / quote preview#
| Id | Required type | Role |
|---|---|---|
reply_preview_row | LinearLayout | Reply preview row |
quote_sender | TextView | Quoted sender |
quote_text | TextView | Quoted text |
ib_close_quote | any View | Close reply preview |
reply_preview_accent | any View | Accent strip (optional) |
Voice recording#
| Id | Required type | Role |
|---|---|---|
audioContainer | any View | Slide-to-cancel bar |
audioTimer | TextView | Recording timer |
audioSlide | any View | Cancel hint |
record_point | any View | Recording pulse dot |
audioLockedControls | any View | Locked recording controls |
audioLockedStop | ImageView | Delete locked recording |
audioLockedSend | ImageView | Send locked recording |
audioLockedTimer | TextView | Locked 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#
| Id | Required type | Role |
|---|---|---|
youtubeInfoRl | RelativeLayout | YouTube info row |
tv_image_youtube | ImageView | Thumbnail |
tv_title_youtube | TextView | Title |
tv_label_youtube | TextView | Label |
Kicked / not a member#
| Id | Required type | Role |
|---|---|---|
kickedFromChat | any View | Overlay shown when the user is not a group member |
kicked_text | TextView | Text inside that overlay |
Link preview (optional)#
| Id | Type | Role |
|---|---|---|
linkPreviewContainer | FrameLayout | Link preview container (optional) |
linkPreviewView | im.diyalog.sdk.controllers.conversation.messages.linkpreview.LinkPreviewView | Link preview (optional) |
Structural tips#
- Keep send and microphone inside
rlActionButtonContainerat the end / bottom offl_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.xmland 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_cancelare presentbtn_alert_neutralis 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
avatarPreviewis anim.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_sendis anim.diyalog.sdk.view.TintImageView- Test: type and send, attach, reply, hold-to-record (if enabled), group kick overlay
Troubleshooting#
| Symptom | Likely cause |
|---|---|
| Still see the SDK default UI | A required id is missing or has the wrong type, or the setter was not called / called after the chat was already open |
| Inflate exception / fallback | Invalid XML, a custom view class missing from the classpath, or a bad drawable reference |
| Avatar crash / bind issues | avatarPreview is not an AvatarView |
| Send button not tinting / wrong type | ib_send is not a TintImageView |
| Mentions / share menu overlap the input | Panel height or gravity differs from the sample; keep bottom alignment like the sample layout |
API summary#
Default SDK layouts you can use as a reference: bar_conversation_normal.xml (chat AppBar) and activity_dialog.xml (fl_send_panel, chat input).