Replacing State Views
Each state view setter accepts an Android layout resource ID (@LayoutRes int). The component inflates the layout when the corresponding state is triggered.
| Setter | State |
|---|---|
setEmptyView(@LayoutRes int) | No data to display |
setErrorView(@LayoutRes int) | An error occurred during data fetching |
setLoadingView(@LayoutRes int) | Data is being fetched |
Example: Custom Empty State
Create a custom layout:- Kotlin
- Java
State Visibility Controls
Hide or show specific state views entirely:| Method | Description |
|---|---|
setEmptyStateVisibility(int) | Show or hide the empty state (View.VISIBLE or View.GONE) |
setErrorStateVisibility(int) | Show or hide the error state |
setLoadingStateVisibility(int) | Show or hide the loading state |
- Kotlin
- Java
Restyling Default State Views
If you want to keep the default state layout but change its appearance, use the text customization setters:Empty State
| Method | Description |
|---|---|
setEmptyStateTitleTextColor(@ColorInt int) | Title text color |
setEmptyStateSubtitleTextColor(@ColorInt int) | Subtitle text color |
setEmptyStateTextTitleAppearance(@StyleRes int) | Title text appearance (font, size, style) |
setEmptyStateTextSubtitleAppearance(@StyleRes int) | Subtitle text appearance |
Error State
| Method | Description |
|---|---|
setErrorStateTitleTextColor(@ColorInt int) | Title text color |
setErrorStateSubtitleTextColor(@ColorInt int) | Subtitle text color |
setErrorStateTextTitleAppearance(@StyleRes int) | Title text appearance |
setErrorStateTextSubtitleAppearance(@StyleRes int) | Subtitle text appearance |
- Kotlin
- Java
Related
- Customization Overview — See all customization categories.