> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# RTL Support

> Show CometChat Android UI Kit components right to left for Arabic and other RTL languages, globally or per component, with layoutDirection.

> [accordion] AI Integration Quick Reference
>
> | Field | Value |
> | - | - |
> | Modules | `chatuikit-core` (setting), `chatuikit-kotlin` (XML Views), `chatuikit-compose` (Jetpack Compose) |
> | Import | `com.cometchat.uikit.core.CometChatLayoutDirection` |
> | Global setting | `UIKitSettings.UIKitSettingsBuilder().setLayoutDirection(...)` at init, `CometChatUIKit.setLayoutDirection(...)` at runtime |
> | Per component | Compose: `layoutDirection` parameter · Views: `setCometChatLayoutDirection(...)` or XML `app:cometchatLayoutDirection` |
> | Values | `CometChatLayoutDirection.AUTO` (default) · `LTR` · `RTL` |
> | Default behavior | `AUTO` follows the app's own direction, so an app in Arabic is RTL with no extra code |
> | Available from | UI Kit 6.4.0 (`chatuikit-kotlin-android` and `chatuikit-compose-android`) |
> | Manifest | `android:supportsRtl="true"` on `<application>` |
> | Related | [Localize](https://www.cometchat.com/docs/ui-kit/android/localize.md) · [Methods](https://www.cometchat.com/docs/ui-kit/android/methods.md) · [Customization Overview](https://www.cometchat.com/docs/ui-kit/android/customization-overview.md) |

## Overview

Languages such as Arabic are read right to left. From UI Kit 6.4.0, in an RTL layout, the UI Kit mirrors its components: avatars, names, buttons, message bubbles, menus and sheets swap sides, and arrows point the other way.

Mirroring the layout doesn't flip the content. The UI Kit keeps every piece of content readable:

* Each message reads in its own direction, so an English message in an Arabic chat still reads left to right.
* Names inside sentences the UI Kit writes keep their order.
* Audio and video players and code blocks stay left to right.

## Layout Direction and Language

Layout direction and language are two separate settings:

| Setting | Decides | Set with |
| - | - | - |
| Layout direction | Which side things sit on | `layoutDirection` (this page) |
| Language | Which strings are shown | The app's locale, or `CometChatLocalize.setLocale` (see [Localize](https://www.cometchat.com/docs/ui-kit/android/localize.md)) |

With the default, `AUTO`, the UI Kit takes the direction Android gives your app, and Android makes an app RTL when its language is RTL. `CometChatLocalize.setLocale` changes the UI Kit's language only, never its direction.

## Before You Start

Declare RTL support in your app's manifest:

```xml AndroidManifest.xml theme={null}
<application
    android:supportsRtl="true"
    ... >
```

Without it, Android lays every `View` out left to right. The Kotlin (XML Views) UI Kit can't mirror at all, and the Jetpack Compose UI Kit can't follow an Arabic app under `AUTO`. The UI Kit doesn't add the flag for you, because it would also mirror your app's own screens.

## Turn On RTL

### Follow the app's language (default)

With `AUTO`, the UI Kit uses the direction the app is already in. Set the app's language with the platform API, and Android makes the whole app RTL, UI Kit included:

> [tab] Kotlin
>
> ```kotlin theme={null}
> import androidx.appcompat.app.AppCompatDelegate
> import androidx.core.os.LocaleListCompat
>
> AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags("ar"))
> ```

A phone set to Arabic has the same effect. See [Localize](https://www.cometchat.com/docs/ui-kit/android/localize.md) for the UI Kit's strings.

### Set it for the whole UI Kit

Pass `setLayoutDirection` to `UIKitSettings` to give every UI Kit component a fixed direction, whatever the language:

> [tab] Kotlin
>
> ```kotlin theme={null}
> import com.cometchat.uikit.core.CometChatLayoutDirection
> import com.cometchat.uikit.core.CometChatUIKit
> import com.cometchat.uikit.core.UIKitSettings
>
> val uiKitSettings = UIKitSettings.UIKitSettingsBuilder()
>     .setRegion(your_region)
>     .setAppId(your_appID)
>     .setAuthKey(your_authKey)
>     .setLayoutDirection(CometChatLayoutDirection.RTL)
>     .build()
>
> CometChatUIKit.init(context, uiKitSettings, callbackListener)
> ```

| Value | Result |
| - | - |
| `CometChatLayoutDirection.AUTO` | Follows the app's direction. This is the default, so apps that don't set it see no change. |
| `CometChatLayoutDirection.LTR` | Every UI Kit component is left to right. |
| `CometChatLayoutDirection.RTL` | Every UI Kit component is right to left. |

### Change it at runtime

Use `CometChatUIKit.setLayoutDirection` to change the direction while the app is running, for example from a settings screen. Read the current value with `CometChatUIKit.getLayoutDirection()`.

> [tab] Kotlin
>
> ```kotlin theme={null}
> CometChatUIKit.setLayoutDirection(CometChatLayoutDirection.RTL)
> activity.recreate() // components on screen keep the direction they started with
>
> val current = CometChatUIKit.getLayoutDirection() // CometChatLayoutDirection.RTL
> ```

> [!NOTE]
>
> Each component reads the global direction when it is created. A screen that is already open keeps its direction until it is recreated. Calling `init()` again keeps the runtime value unless its `UIKitSettings` sets `setLayoutDirection` itself.

## Set It Per Component

Every main UI Kit component takes its own direction. It overrides the global setting for that component and everything inside it.

> [tab] Kotlin (XML Views)
>
> ```xml theme={null}
> <com.cometchat.uikit.kotlin.presentation.messagelist.ui.CometChatMessageList
>     android:id="@+id/message_list"
>     android:layout_width="match_parent"
>     android:layout_height="match_parent"
>     app:cometchatLayoutDirection="ltr" />
> ```
>
> ```kotlin theme={null}
> // or in code
> messageList.setCometChatLayoutDirection(CometChatLayoutDirection.LTR)
> ```

> [tab] Jetpack Compose
>
> ```kotlin theme={null}
> // The whole kit is RTL, but this list stays LTR.
> CometChatMessageList(
>     user = user,
>     layoutDirection = CometChatLayoutDirection.LTR
> )
> ```

Leave it unset, or pass `AUTO`, to inherit the direction from the UI Kit component around it, or from the global setting. In Compose, pass `layoutDirection` by name.

These components take a direction of their own:

| Chat | Messages | Calls and more |
| - | - | - |
| [Conversations](https://www.cometchat.com/docs/ui-kit/android/conversations.md) | [Message Header](https://www.cometchat.com/docs/ui-kit/android/message-header.md) | [Call Buttons](https://www.cometchat.com/docs/ui-kit/android/call-buttons.md) |
| [Users](https://www.cometchat.com/docs/ui-kit/android/users.md) | [Message List](https://www.cometchat.com/docs/ui-kit/android/message-list.md) | [Call Logs](https://www.cometchat.com/docs/ui-kit/android/call-logs.md) |
| [Groups](https://www.cometchat.com/docs/ui-kit/android/groups.md) | [Message Composer](https://www.cometchat.com/docs/ui-kit/android/message-composer.md) | [Incoming Call](https://www.cometchat.com/docs/ui-kit/android/incoming-call.md) |
| [Group Members](https://www.cometchat.com/docs/ui-kit/android/group-members.md) | [Threaded Messages Header](https://www.cometchat.com/docs/ui-kit/android/threaded-messages-header.md) | [Outgoing Call](https://www.cometchat.com/docs/ui-kit/android/outgoing-call.md) |
| [Search](https://www.cometchat.com/docs/ui-kit/android/search.md) | [Pinned Messages](https://www.cometchat.com/docs/ui-kit/android/pinned-messages.md) | [Ongoing Call](https://www.cometchat.com/docs/ui-kit/android/ongoing-call.md) |
| [Notification Feed](https://www.cometchat.com/docs/ui-kit/android/notification-feed.md) | [Saved Messages](https://www.cometchat.com/docs/ui-kit/android/saved-messages.md) | [AI Assistant Chat History](https://www.cometchat.com/docs/ui-kit/android/ai-assistant-chat-history.md) |

Message bubbles, the reaction list, the create-poll and message-information screens, the sticker keyboard, the media recorder and the AI views take one too.

### Base components

Base components (avatar, badge, date, receipts, status indicator, search box, toolbar, list items, popup menus) have no direction setting. Inside a UI Kit component they follow it. Used on their own, they follow the global setting, and under `AUTO` the app.

## Which Setting Wins

When settings disagree, the first rule that gives a direction wins:

1. Audio and video players, and code blocks, are always left to right.
2. The component's own direction, when it is `LTR` or `RTL`.
3. The nearest UI Kit component around it that has its own direction.
4. The global setting, when it is `LTR` or `RTL`.
5. The app's own direction.

Use the UI Kit's setting to change a component's direction. With a global `LTR` or `RTL`, setting `android:layoutDirection` on a parent view or providing `LocalLayoutDirection` around a component doesn't change it, because each component applies the global setting at its root.

| I want | Global | Component | Language |
| - | - | - | - |
| My app is already Arabic and RTL | leave `AUTO` | nothing | the app's |
| An English app with the chat in Arabic and RTL | `RTL` | nothing | `CometChatLocalize.setLocale(context, Language.ARABIC)` |
| Everything RTL except one component | `RTL` | `LTR` on that one | any |
| An RTL app with one component LTR | leave `AUTO` | `LTR` on that one | any |
| Only the chat screen RTL in an LTR app | leave `AUTO` | `RTL` on the screen's components | optional |

## What the UI Kit Does for You

* **Overlays follow the component that opens them.** Menus, dialogs, bottom sheets and popups a UI Kit component opens use that component's direction, even though they draw in a window of their own.
* **Screens the UI Kit starts keep the direction.** The image and video viewers open in the direction of the component that started them. Call screens follow the global setting.
* **Short messages follow the component.** Messages such as "Message pinned" appear as a snackbar in the component's direction. In the Compose UI Kit the bar is drawn in Compose, so it mirrors without `supportsRtl`.
* **Your app's own screens don't change.** The UI Kit never changes the app's direction or locale.

## What Changes in RTL

### Layout

Everything that has a side moves to the other one: avatars, titles, subtitles, timestamps, unread badges, receipts, buttons, the composer's actions, message bubbles, menus, sheets, swipe actions and horizontal lists. Sent messages sit on the left and received messages on the right. Swipe to reply goes toward the left.

Labels the UI Kit draws (toolbar titles, dialog titles and text, menu items, search hints, section headers, empty and error states) sit at the component's start, which is the right in RTL.

### Icons

| Icon | In RTL |
| - | - |
| Back and forward arrows, send, reply, reply in thread, message privately, call-direction arrows (incoming, outgoing, missed), video camera, copy, new chat, chat history, sticker, bullet list | Mirror |
| Phone handset, microphone, attach, emoji, close, search, receipt ticks, pin, media controls, file types, logos, flags | Stay as drawn |

Icons you pass into the UI Kit are drawn as you give them. For an arrow that should mirror, use a vector drawable with `android:autoMirrored="true"`.

### What doesn't mirror

* **Audio and video players**, including voice notes and the recorder's playback row: controls and progress bars stay left to right in every language. The card around them follows the component.
* **Code blocks and inline code** stay left to right.

### Text, numbers and dates

* **Each text reads in its own direction.** Its first letter decides: a message that starts with an English letter reads left to right, one that starts with an Arabic letter reads right to left, in an RTL or an LTR screen. Text with no letters at all, such as `123 + 456 = 579`, reads left to right, in message bubbles and while you type it in the composer.
* **Names keep their place.** Sentences the UI Kit writes, such as group action lines ("X added Y"), are translated, and the names, numbers and links inside them can't scramble the sentence.
* **Numbers use the language's own digits.** In Arabic, dates, times, counts, file sizes, recorder timers and media durations use Arabic digits (٠١٢٣٤٥٦٧٨٩), even where the phone's region uses Western digits. Hindi uses Devanagari digits (०–९), and every other language uses 0–9. An English app set to RTL keeps 0–9.
* **Dates follow the app's language**, including after an in-app language switch. Text you supply yourself, for example through a date formatter callback, is shown as given.

## Custom Views in RTL

Views you pass into the UI Kit (view slots, custom message templates, custom bubbles) are placed inside the component's direction. Use direction-aware values so they mirror with the rest of the UI Kit:

| Instead of | Use (Views) | Use (Compose) |
| - | - | - |
| `paddingLeft`, `layout_marginRight` | `paddingStart`, `layout_marginEnd` | `Modifier.padding(start = …, end = …)` |
| `setPadding(left, top, right, bottom)` | `setPaddingRelative(start, top, end, bottom)` | `PaddingValues(start = …, end = …)` |
| `gravity="left"` | `gravity="start"` | `Alignment.Start`, `Alignment.CenterStart` |
| `textAlignment="textStart"` for labels | `textAlignment="viewStart"` | `TextAlign.Start` |
| `resources.configuration.layoutDirection` | `view.layoutDirection` | `LocalLayoutDirection.current` |

Read the direction from the view or the composition, never from the app's configuration: a UI Kit component can be set the other way from the app.

### Your own overlays

A dialog or popup you open from a custom view starts a new window, which follows the app, not the component. Copy the direction across:

> [tab] Kotlin (XML Views)
>
> ```kotlin theme={null}
> dialog.window?.decorView?.layoutDirection = anchorView.layoutDirection
> dialog.show()
> ```

> [tab] Jetpack Compose
>
> ```kotlin theme={null}
> val direction = LocalLayoutDirection.current // the opener's
> Dialog(onDismissRequest = onDismiss) {
>     CompositionLocalProvider(LocalLayoutDirection provides direction) {
>         MyDialogContent()
>     }
> }
> ```

## Upgrading From an Earlier Version

| Change | What to do |
| - | - |
| The Views UI Kit no longer adds `android:supportsRtl` to your app | Add `android:supportsRtl="true"` to your `<application>` to keep RTL. |
| `CometChatLocalize.setLocale` no longer changes the layout direction | For RTL, set the app language with `AppCompatDelegate.setApplicationLocales`, or call `setLayoutDirection(CometChatLayoutDirection.RTL)`. |
| `CometChatLocalize.isRtl(context)` is deprecated. It reports the app's direction, not the component's, and is removed in the next major version | Read `view.layoutDirection` (Views) or `LocalLayoutDirection.current` (Compose). |
| Views: `setBubbleMargin`, `setLeftBubbleMargin` and `setRightBubbleMargin` on Message List and Thread Header take `start` and `end` instead of `left` and `right` | Calls that pass the values by position compile unchanged. Rename `left =` and `right =` named arguments to `start =` and `end =`. The margins now apply as start and end, so they mirror in RTL. |
| Compose components take a new, optional `layoutDirection` parameter | No change. Existing Compose calls compile unchanged, and libraries compiled against 6.3.0 keep working without a rebuild. |
| Short messages are snackbars instead of toasts | No code change. |
| Group action lines are translated and say "You" for the logged-in user | No code change. See [Localize](https://www.cometchat.com/docs/ui-kit/android/localize.md#group-action-messages). |

## Languages

The UI Kit ships Arabic translations. For another RTL language, such as Hebrew, Persian or Urdu, add its strings as described in [Localize](https://www.cometchat.com/docs/ui-kit/android/localize.md). With the app's language set to it, `AUTO` lays the UI Kit out right to left.

## Next Steps

> [card] [Localize](https://www.cometchat.com/docs/ui-kit/android/localize.md)
>
> Set the UI Kit's language and translations

> [card] [Methods](https://www.cometchat.com/docs/ui-kit/android/methods.md)
>
> UIKitSettings and CometChatUIKit reference

> [card] [Custom View Slots](https://www.cometchat.com/docs/ui-kit/android/customization-view-slots.md)
>
> Replace parts of a component with your own views

> [card] [Troubleshooting](https://www.cometchat.com/docs/ui-kit/android/troubleshooting.md)
>
> Common RTL questions


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.