# Channel Header

`ChannelHeaderView` is a component that can be used on a message list screen. It shows the channel's name and avatar, members and online members count, current connection status, and a back button.

| Light Mode                                                            | Dark Mode                                                                 |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| ![Light_mode](/data/docs/chat-sdk/android/v7-latest/_assets/channel_header.png) | ![Dark_mode](/data/docs/chat-sdk/android/v7-latest/_assets/channel_header_dark.png) |

## Usage

To use `ChannelHeaderView`, include it in your XML layout as shown below:

```xml
<io.getstream.chat.android.ui.feature.messages.header.ChannelHeaderView
    android:id="@+id/channelHeaderView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
```

We recommend using the `ChannelHeaderViewModel` that gets all needed data from the Stream API and then renders it in the view.

The basic setup of the ViewModel and connecting it to the view is done as follows:

<tabs>

<tabs-item value="kotlin" label="Kotlin">

```kotlin
// Initialize ViewModel
val viewModel: ChannelHeaderViewModel by viewModels {
    ChannelViewModelFactory(cid = "messaging:123")
}

// Bind the View and ViewModel
viewModel.bindView(channelHeaderView, lifecycleOwner)
```

</tabs-item>

<tabs-item value="java" label="Java">

```java
// Initialize ViewModel
ViewModelProvider.Factory factory = new ChannelViewModelFactory.Builder()
        .cid("messaging:123")
        .build();
ViewModelProvider provider = new ViewModelProvider(this, factory);
ChannelHeaderViewModel viewModel = provider.get(ChannelHeaderViewModel.class);

// Bind the View and ViewModel
ChannelHeaderViewModelBinding.bind(viewModel, channelHeaderView, getViewLifecycleOwner());
```

</tabs-item>

</tabs>

By default, the ViewModel will make the view display useful channel information and the "Searching for network" state when needed.

| Light Mode                                                                                | Dark Mode                                                                                     |
| ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| ![Light_mode](/data/docs/chat-sdk/android/v7-latest/_assets/channel_header_waiting_for_network.png) | ![Dark_mode](/data/docs/chat-sdk/android/v7-latest/_assets/channel_header_waiting_for_network_dark.png) |

## Handling Actions

By default, `ChannelHeaderView` displays all the views described above, but none of them come with a default click behavior. You can change that by setting the following listeners:

<tabs>

<tabs-item value="kotlin" label="Kotlin">

```kotlin
channelHeaderView.setBackButtonClickListener {
    // Handle back button click
}
channelHeaderView.setAvatarClickListener {
    // Handle avatar click
}
channelHeaderView.setTitleClickListener {
    // Handle title click
}
channelHeaderView.setSubtitleClickListener {
    // Handle subtitle click
}
```

</tabs-item>

<tabs-item value="java" label="Java">

```java
channelHeaderView.setBackButtonClickListener(() -> {
    // Handle back button click
});
channelHeaderView.setAvatarClickListener(() -> {
    // Handle avatar click
});
channelHeaderView.setTitleClickListener(() -> {
    // Handle title click
});
channelHeaderView.setSubtitleClickListener(() -> {
    // Handle subtitle click
});
```

</tabs-item>

</tabs>

## Customization

### Using XML Attributes

The appearance of `ChannelHeaderView` can be conveniently modified using its XML attributes.

```xml
<io.getstream.chat.android.ui.feature.messages.header.ChannelHeaderView
    android:id="@+id/channelHeaderView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:streamUiChannelHeaderShowBackButton="false"
    app:streamUiChannelHeaderTitleTextColor="#FF0000"
    app:streamUiChannelHeaderDefaultLabelTextStyle="bold" />
```

The example above hides the back button, makes the title text red and subtitle text bold.

| Before                                                                | After                                                                              |
| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| ![Light_mode](/data/docs/chat-sdk/android/v7-latest/_assets/channel_header.png) | ![Dark_mode](/data/docs/chat-sdk/android/v7-latest/_assets/channel_header_customization.png) |

A full list of available XML attributes is available [here](https://github.com/GetStream/stream-chat-android/blob/main/stream-chat-android-ui-components/src/main/res/values/attrs_channel_header_view.xml).


---

This page was last updated at 2026-04-10T16:24:28.037Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/sdk/android/v7/ui/message-components/channel-header/](https://getstream.io/chat/docs/sdk/android/v7/ui/message-components/channel-header/).