/StateLayout

An android library which managing layout view states.

Primary LanguageKotlin

StateLayout

GIF

Usage

  • Add state layout to outside of your main content
<com.yonder.statelayout.StateLayoutView
    android:id="@+id/stateLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

  <-- Your main content --> 

 </com.yonder.statelayout.StateLayoutView>

Code:

    stateLayout.setState(State.LOADING)
    stateLayout.setState(State.EMPTY)
    stateLayout.setState(State.ERROR) 
    stateLayout.setState(State.CONTENT)
  • Customize if you need
 <com.yonder.statelayout.StateLayoutView
    android:id="@+id/errorStateLayoutView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:loadingGravity="top"
    app:errorDrawable="@drawable/ic_error_outline_24"
    app:textErrorButtonTryAgain="@string/title_btn_try_again"
    app:textErrorDetail="@string/title_error_detail"
    app:textErrorTitle="@string/title_error"
    app:textLoading= "@string/title_loading"
    app:textEmpty= "@string/title_empty"
    app:emptyIconDrawable= "@drawable/ic_empty_box_24"
    app:defaultMargin= "8">

Setup

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
       implementation 'com.github.yusufonderd:StateLayout:0.1.1'
}