- Add the JitPack repository to your build.gradle at the end of repositories:
repositories {
...
maven { url 'https://jitpack.io' }
}
- Add the dependency
implementation 'com.github.ctrlbytes:StateLayout:LATEST_VERSION_HERE'
<com.ctrlbytes.statelayout.StateLayout
android:id="@+id/state_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:buttonText="@string/try_again"
app:emptyImage="@drawable/ic_inbox"
app:errorImage="@drawable/ic_cactus">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Inbox Content" />
</com.ctrlbytes.statelayout.StateLayout>
showContent()
showLoading()
showError(message)
showEmpty(message)
onButtonClick {
// handle button click
}
Attribute |
Usage |
buttonText |
Retry Button Text |
emptyImage |
Empty State Icon |
errorImage |
Error State Icon |
loadingView |
Custom Loading View |
retryButtonStyle |
Retry Button Style |