LayoutListener. This listener provides callbacks for call layout changes, participant list visibility, and Picture-in-Picture (PiP) mode state changes.
Prerequisites
- An active call session
- Access to the
CallSessioninstance
Register Listener
Register aLayoutListener to receive layout event callbacks:
- Kotlin
- Java
The listener is automatically removed when the
LifecycleOwner (Activity/Fragment) is destroyed, preventing memory leaks.Callbacks
onCallLayoutChanged
Triggered when the call layout changes between Tile and Spotlight modes.- Kotlin
- Java
Use Cases:
- Update layout toggle button icon
- Adjust custom UI overlays
- Log layout preference analytics
onParticipantListVisible
Triggered when the participant list panel becomes visible.- Kotlin
- Java
- Log analytics events
- Adjust custom UI elements
- Pause other UI animations
onParticipantListHidden
Triggered when the participant list panel is hidden.- Kotlin
- Java
- Restore UI elements
- Resume animations
- Update button states
onPictureInPictureLayoutEnabled
Triggered when Picture-in-Picture (PiP) mode is enabled.- Kotlin
- Java
- Hide call control buttons
- Simplify UI for small window
- Track PiP feature usage
onPictureInPictureLayoutDisabled
Triggered when Picture-in-Picture (PiP) mode is disabled.- Kotlin
- Java
- Restore call control buttons
- Show full call UI
- Resume normal layout
Complete Example
Here’s a complete example handling all layout events:- Kotlin
- Java
Controlling Layout Programmatically
You can change the layout and PiP state programmatically:Change Layout
- Kotlin
- Java
Enable/Disable PiP
- Kotlin
- Java
Initial Layout Configuration
Set the initial layout when joining a session:- Kotlin
- Java
Callbacks Summary
Next Steps
Layout & UI
Control layout programmatically
Session Settings
Configure initial layout settings