Gihub地址:https://github.com/huclengyue/StateLayoutWithKotlin
这个项目是根据 StateLayout 项目而来,感谢原作者的贡献,我本人在功能实现上只做了稍许改动,主要的不同在于这个是完全使用Kotlin编写的,可以看做是一个kotlin练手项目。 由于我也是刚刚使用Kotlin,使用还不是很熟练,如果在写法、功能实现上有不够优雅的地方欢迎指正!
更新 优化了各个View的加载逻辑,在调用相应布局时才会加载,节约资源。 删除了部分无用的方法 下面是原项目的readme部分
演示 StateLayout用法 引入布局 用法与ScrollView一致,只允许一个根布局
<com.fingdo.statelayout.StateLayout android:id="@+id/state_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 内容布局 one root view --> </com.fingdo.statelayout.StateLayout> 布局设置图标和文字 <declare-styleable name="StateLayout"> <!-- 错误提示图标 --> <attr name="errorImg" format="reference" /> <!-- 错误提示文字 --> <attr name="errorText" format="string" /> <!-- 空数据提示图标 --> <attr name="emptyImg" format="reference" /> <!-- 空数据提示文字 --> <attr name="emptyText" format="string" /> <!