Need help with StateLayout?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

lufficc
426 Stars 70 Forks 30 Commits 4 Opened issues

Description

A custom layout that can easily switch different states(like empty,error,progress,content) with animations.

Services available

!
?

Need anything else?

Contributors list

No Data

StateLayout

A custom layout that can easily switch different states(like empty,error,progress,content) with animations.

gif

An example usage can be found here lufficc/iShuiHui

Usage

Add the dependencies to your project:

gradle

    dependencies {
        compile 'com.lufficc:stateLayout:0.1.1'
    }

maven

    
      com.lufficc
      stateLayout
      0.1.1
      pom
    

Add StateLayout to your layout file

Remember ,StateLayout can only hold one direct child

    
    
        
            
            
        
    

operation in java

        stateLayout.showErrorView(); //switch to error view
        stateLayout.showErrorView(msg); //switch to error view with a message

    stateLayout.showEmptyView();  //switch to empty view
    stateLayout.showEmptyView(msg);  //switch to empty view with a message

    stateLayout.showProgressView();  //switch to progress view
    stateLayout.showProgressView(msg);  //switch to progress view with a message

    stateLayout.showContentView();  //switch to your content view

custom

Animation

you can custom your own animation by implements ViewAnimProvider interface,

by default,there are two simple animations,
FadeViewAnimProvider
and
FadeScaleViewAnimProvider

public interface ViewAnimProvider {
    Animation showAnimation();

Animation hideAnimation();

}

//or

stateLayout.setHideAnimation(yourAnimation); stateLayout.setShowAnimation(yourAnimation);

stateLayout.setViewSwitchAnimProvider(new FadeViewAnimProvider()); //user it

attrs

| attr | for | |----------------------|----------------| | app:errorDrawable | custom the error drawable | | app:emptyDrawable | custom the empty drawable | | app:progressView | custom your own progress view |

listener

    setErrorAction(OnClickListener onErrorButtonClickListener); //set a callback called where error view is clicked,
    // you can tetry load data,for example

setEmptyAction(OnClickListener onEmptyButtonClickListener); // //set a callback called where empty view is clicked

if you find a bug or have good suggestion ,find me here https://lufficc.com

License

Copyright 2016 Copyright 2016 lufficc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.