PageStateLayout
一款簡(jiǎn)單的頁(yè)面切換布局組件
https://github.com/cn-ljb/PageStateLayout
集成方式
- 1、Project的build.gradle文件添加如下代碼:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- 2、主Module的build.gradle添加依賴:
//page layout
implementation 'com.github.cn-ljb:PageStateLayout:1.0.0'
代碼示例
-
layout.xml中使用
<com.ljb.page.PageStateLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/page_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" app:page_empty="@layout/layout_page_empty" app:page_error="@layout/layout_page_error" app:page_load="@layout/layout_page_loading" app:page_content="@layout/layout_page_content"/> -
或者code中使用
page_layout.setLoadView(R.layout.layout_page_loading) page_layout.setEmptyView(R.layout.layout_page_empty) page_layout.setErrorView(R.layout.layout_page_error) page_layout.setContentView(R.layout.layout_page_content) -
代碼切換布局
page_layout.setPage(pageState) -
pageState取值
PageState.STATE_SUCCESS -> 成功頁(yè)面 PageState.STATE_EMPTY -> 空頁(yè)面 PageState.STATE_ERROR -> 錯(cuò)誤頁(yè)面 PageState.STATE_LOADING -> 加載頁(yè)面
演示

page_layout.gif