StateLayout

StateLayout is a custom framelayout used to control view state in android
screenshot

Adding to your project

  1. Add the JitPack repository to your build.gradle at the end of repositories:
repositories {
  ...
  maven { url 'https://jitpack.io' }
}
  1. Add the dependency
implementation 'com.github.ctrlbytes:StateLayout:LATEST_VERSION_HERE'

Usage

<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
}

Attributes

Attribute Usage
buttonText Retry Button Text
emptyImage Empty State Icon
errorImage Error State Icon
loadingView Custom Loading View