/capa

a lightly state layout with animation for android.

Primary LanguageJava

Capa

a lightly state layout for android.

gif

Start

quick integration with 3 minutes

integration

use jitpack in your module.

allProjects {
  repositories {
    maven { url "https://www.jitpack.io" }
  }
}

depend these in your build.gralde.

dependencies {
  compile "com.github.lsxiao.capa:1.0.5"
}

Usage

init

use com.lsxiao.capa.CapaLayout to wrap your own content layout or view.

cp_state is the attribute for first show state layout

default is load state(load,empty,error,content)

<com.lsxiao.capa.CapaLayout
    android:id="@+id/capa_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    app:cp_anim_in="@anim/capa_fade_in"
    app:cp_anim_out="@anim/capa_fade_out"

    app:cp_empty_layout="@layout/capa_empty_layout"
    app:cp_error_layout="@layout/capa_error_layout"
    app:cp_network_error_layout="@layout/capa_network_error_layout"
    app:cp_load_layout="@layout/capa_load_layout"

    app:cp_anim_enable="true"
    app:cp_state="load">

    <!-- your content layout or view-->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</com.lsxiao.capa.CapaLayout>

switch state

cataLayout.toLoad();

cataLayout.toEmpty();

cataLayout.toError();

cataLayout.toNetworkError();

cataLayout.toContent();

animation

not show animation

animation default is enabled.

use app:cp_anim_enable="false" to change,or use animNone() method in your code.

capaLayout.animNone();//not show animation.

default inner animation

capaLayout.animFade();

capaLayout.animeSlideInTop();

capaLayout.animeSlideInBottom();

custom animation

capaLayout.animIn(...);

capaLayout.animOut(...);

or

app:cp_anim_in="..."
app:cp_anim_out="..."

get state view

capaLayout.getLoadView();

capaLayout.getEmptyView();

capaLayout.getErrorView();

capaLayout.getContentView();

capaLayout.getNetworkView();

How to contribute

welcome pr.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • lsxiao - Android developer - lsxiao See also the list of contributors who participated in this project.

License

MIT